/** * Get the znode string corresponding to a replicaId * @param replicaId * @return znode */ public String getZNodeForReplica(int replicaId) { // return a newly created path but don't update the cache of paths // This is mostly needed for tests that attempt to create meta replicas // from outside the master return Optional.ofNullable(metaReplicaZNodes.get(replicaId)) .orElseGet(() -> metaReplicaZNodes.get(DEFAULT_REPLICA_ID) + "-" + replicaId); }
/** * Is it the default meta replica's znode * @param znode * @return true or false */ public boolean isDefaultMetaReplicaZnode(String znode) { return metaReplicaZNodes.get(DEFAULT_REPLICA_ID).equals(znode); }
private static String getRpcClientClass(Configuration conf) { String rpcClientClass = conf.get(CUSTOM_RPC_CLIENT_IMPL_CONF_KEY); if (rpcClientClass == null) { return NettyRpcClient.class.getName(); } String mappedName = DEPRECATED_NAME_MAPPING.get(rpcClientClass); return mappedName == null ? rpcClientClass : mappedName; }
@Override public OpWriteBlockProto.Builder set(OpWriteBlockProto.Builder builder, Enum<?> storageType) { Object protoEnum = name2ProtoEnum.get(storageType.name()); try { setStorageTypeMethod.invoke(builder, protoEnum); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } return builder; } };
private String opMeterName(Object op) { MetaTableOps ops = opsNameMap.get(op.getClass()); String opMeterName = ""; switch (ops) { case GET: opMeterName = "MetaTable_get_request"; break; case PUT: opMeterName = "MetaTable_put_request"; break; case DELETE: opMeterName = "MetaTable_delete_request"; break; default: break; } return opMeterName; }
private String opWithClientMeterName(Object op) { String clientIP = RpcServer.getRemoteIp() != null ? RpcServer.getRemoteIp().toString() : ""; if (clientIP.isEmpty()) { return ""; } MetaTableOps ops = opsNameMap.get(op.getClass()); String opWithClientMeterName = ""; switch (ops) { case GET: opWithClientMeterName = String.format("MetaTable_client_%s_get_request", clientIP); break; case PUT: opWithClientMeterName = String.format("MetaTable_client_%s_put_request", clientIP); break; case DELETE: opWithClientMeterName = String.format("MetaTable_client_%s_delete_request", clientIP); break; default: break; } return opWithClientMeterName; }
/** * @return the old desciption of the peer */ ReplicationPeerDescription preTransitPeerSyncReplicationState(String peerId, SyncReplicationState state) throws DoNotRetryIOException { ReplicationPeerDescription desc = checkPeerExists(peerId); SyncReplicationState fromState = desc.getSyncReplicationState(); EnumSet<SyncReplicationState> allowedToStates = allowedTransition.get(fromState); if (allowedToStates == null || !allowedToStates.contains(state)) { throw new DoNotRetryIOException("Can not transit current cluster state from " + fromState + " to " + state + " for peer id=" + peerId); } return desc; }
@Override public void reduce(ImmutableBytesWritable key, Iterator<Put> values, OutputCollector<ImmutableBytesWritable, Put> output, Reporter reporter) throws IOException { String strKey = Bytes.toString(key.get()); List<Put> result = new ArrayList<>(); while (values.hasNext()) result.add(values.next()); if (relation.keySet().contains(strKey)) { Set<String> set = relation.get(strKey); if (set != null) { assertEquals(set.size(), result.size()); } else { throwAccertionError("Test infrastructure error: set is null"); } } else { throwAccertionError("Test infrastructure error: key not found in map"); } }
/** * Is it the default meta replica's znode * @param znode * @return true or false */ public boolean isDefaultMetaReplicaZnode(String znode) { return metaReplicaZNodes.get(DEFAULT_REPLICA_ID).equals(znode); }
/** * Get the znode string corresponding to a replicaId * @param replicaId * @return znode */ public String getZNodeForReplica(int replicaId) { // return a newly created path but don't update the cache of paths // This is mostly needed for tests that attempt to create meta replicas // from outside the master return Optional.ofNullable(metaReplicaZNodes.get(replicaId)) .orElseGet(() -> metaReplicaZNodes.get(DEFAULT_REPLICA_ID) + "-" + replicaId); }
private static String getRpcClientClass(Configuration conf) { String rpcClientClass = conf.get(CUSTOM_RPC_CLIENT_IMPL_CONF_KEY); if (rpcClientClass == null) { return NettyRpcClient.class.getName(); } String mappedName = DEPRECATED_NAME_MAPPING.get(rpcClientClass); return mappedName == null ? rpcClientClass : mappedName; }
/** * Get the znode string corresponding to a replicaId * @param replicaId * @return znode */ public String getZNodeForReplica(int replicaId) { // return a newly created path but don't update the cache of paths // This is mostly needed for tests that attempt to create meta replicas // from outside the master return Optional.ofNullable(metaReplicaZNodes.get(replicaId)) .orElseGet(() -> metaReplicaZNodes.get(DEFAULT_REPLICA_ID) + "-" + replicaId); }
private static String getRpcClientClass(Configuration conf) { String rpcClientClass = conf.get(CUSTOM_RPC_CLIENT_IMPL_CONF_KEY); if (rpcClientClass == null) { return NettyRpcClient.class.getName(); } String mappedName = DEPRECATED_NAME_MAPPING.get(rpcClientClass); return mappedName == null ? rpcClientClass : mappedName; }
@Override public V get(@Nullable Object key) { Integer index = keyIndex.get(key); if (index == null) { return null; } else { return getValue(index); } }
@Override public boolean contains(@Nullable Object object) { if (object instanceof Entry) { Entry<?, ?> entry = (Entry<?, ?>) object; V value = map().get(entry.getKey()); return value != null && value.equals(entry.getValue()); } return false; }
/** * Returns an immutable list of the values for the given key. If no mappings * in the multimap have the provided key, an empty immutable list is * returned. The values are in the same order as the parameters used to build * this multimap. */ @Override public ImmutableList<V> get(@Nullable K key) { // This cast is safe as its type is known in constructor. ImmutableList<V> list = (ImmutableList<V>) map.get(key); return (list == null) ? ImmutableList.<V>of() : list; }
@Override public V get(@Nullable Object key) { Integer keyIndex = keyToIndex().get(key); return (keyIndex == null) ? null : getValue(keyIndex); }
@Override public V put(K key, V value) { Integer index = keyIndex.get(key); if (index == null) { throw new IllegalArgumentException( getKeyRole() + " " + key + " not in " + keyIndex.keySet()); } return setValue(index, value); }