@Override public String toString() { String tiers = Joiner.on(", ").join(mTiers.stream() .map(tier -> tier.getTierName() + "=" + tier.getValue()) .collect(Collectors.toList())); return String.format("TieredIdentity(%s)", tiers); }
LocalityTier scriptTier = scriptIdentity.getTier(i); Preconditions.checkState(scriptTier.getTierName().equals(tierName)); value = scriptTier.getValue(); && tiers.get(0).getValue() == null) { String name = NetworkAddressUtils.getLocalNodeName(conf); tiers.set(0, new LocalityTier(Constants.LOCALITY_NODE, name));
return false; String otherTierValue = otherTier.getValue(); if (tier.getValue() != null && tier.getValue().equals(otherTierValue)) { return true; if (Constants.LOCALITY_NODE.equals(tier.getTierName())) { try { String tierIpAddress = NetworkAddressUtils.resolveIpAddress(tier.getValue()); String otherTierIpAddress = NetworkAddressUtils.resolveIpAddress(otherTierValue); if (tierIpAddress != null && tierIpAddress.equals(otherTierIpAddress)) {
return false; String otherTierValue = otherTier.getValue(); if (mValue != null && mValue.equals(otherTierValue)) { return true;
LocalityTier scriptTier = scriptIdentity.getTier(i); Preconditions.checkState(scriptTier.getTierName().equals(tierName)); value = scriptTier.getValue(); && tiers.get(0).getValue() == null) { String name = NetworkAddressUtils.getLocalNodeName(); tiers.set(0, new LocalityTier(Constants.LOCALITY_NODE, name));
@Override public String toString() { String tiers = Joiner.on(", ").join(mTiers.stream() .map(tier -> tier.getTierName() + "=" + tier.getValue()) .collect(Collectors.toList())); return String.format("TieredIdentity(%s)", tiers); }
@Test public void chooseClosestTier() throws Exception { List<BlockWorkerInfo> workers = new ArrayList<>(); workers.add(worker(Constants.GB, "node2", "rack3")); workers.add(worker(Constants.GB, "node3", "rack2")); workers.add(worker(Constants.GB, "node4", "rack3")); LocalFirstPolicy policy; WorkerNetAddress chosen; // local rack policy = LocalFirstPolicy.create(TieredIdentityFactory.fromString("node=node1,rack=rack2", sConf), sConf.getBoolean(PropertyKey.LOCALITY_COMPARE_NODE_IP)); chosen = policy.getWorkerForNextBlock(workers, Constants.GB); assertEquals("rack2", chosen.getTieredIdentity().getTier(1).getValue()); // local node policy = LocalFirstPolicy.create(TieredIdentityFactory.fromString("node=node4,rack=rack3", sConf), sConf.getBoolean(PropertyKey.LOCALITY_COMPARE_NODE_IP)); chosen = policy.getWorkerForNextBlock(workers, Constants.GB); assertEquals("node4", chosen.getTieredIdentity().getTier(0).getValue()); }
@Test public void chooseClosestTierAvoidEviction() throws Exception { List<BlockWorkerInfo> workers = new ArrayList<>(); workers.add(worker(Constants.GB, Constants.MB, "node2", "rack3")); workers.add(worker(Constants.GB, 0, "node3", "rack2")); workers.add(worker(Constants.GB, 0, "node4", "rack3")); FileWriteLocationPolicy policy; WorkerNetAddress chosen; // local rack with enough availability policy = new LocalFirstAvoidEvictionPolicy( TieredIdentityFactory.fromString("node=node2,rack=rack3", mConf), mConf); chosen = policy.getWorkerForNextBlock(workers, Constants.GB); assertEquals("node4", chosen.getTieredIdentity().getTier(0).getValue()); }
/** * Converts wire type to proto type. * * @param localityTier the wire representation to convert * @return converted proto representation */ public static alluxio.grpc.LocalityTier toProto(TieredIdentity.LocalityTier localityTier) { alluxio.grpc.LocalityTier.Builder tier = alluxio.grpc.LocalityTier.newBuilder().setTierName(localityTier.getTierName()); if (localityTier.getValue() != null) { tier.setValue(localityTier.getValue()); } return tier.build(); }