@Before public void setup() throws InjectionException { final Configuration conf = Tang.Factory.getTang() .newConfigurationBuilder() .bindImplementation(MatrixFactory.class, MatrixJBLASFactory.class) .build(); final MatrixFactory matrixFactory = Tang.Factory.getTang().newInjector(conf).getInstance(MatrixFactory.class); final int numInput = 3; final int numBatch = 2; this.input = matrixFactory.create( new float[] {1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f}, numInput, numBatch); this.expectedOutput = matrixFactory.create( new float[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }, numInput, numBatch); this.expectedDerivative = matrixFactory.create( new float[] {1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f}, numInput, numBatch); }
/** * Writes driver configuration to disk. * * @param jobFolder The folder in which the job is staged. * @param jobId id of the job to be submitted * @param clientRemoteId The client remote id * @return the configuration * @throws IOException */ public Configuration writeConfiguration( final File jobFolder, final String jobId, final String clientRemoteId) throws IOException { final File driverFolder = new File(jobFolder, PreparedDriverFolderLauncher.DRIVER_FOLDER_NAME); final Configuration driverConfiguration1 = driverConfigurationProvider.getDriverConfiguration( jobFolder.toURI(), clientRemoteId, jobId, Constants.DRIVER_CONFIGURATION_WITH_HTTP_AND_NAMESERVER); final ConfigurationBuilder configurationBuilder = Tang.Factory.getTang().newConfigurationBuilder(); for (final ConfigurationProvider configurationProvider : this.configurationProviders) { configurationBuilder.addConfiguration(configurationProvider.getConfiguration()); } final Configuration providedConfigurations = configurationBuilder.build(); final Configuration driverConfiguration = Configurations.merge( driverConfiguration1, Tang.Factory.getTang() .newConfigurationBuilder() .bindNamedParameter(JobSubmissionDirectory.class, driverFolder.toString()) .build(), providedConfigurations); final File driverConfigurationFile = new File(driverFolder, fileNames.getDriverConfigurationPath()); configurationSerializer.toFile(driverConfiguration, driverConfigurationFile); return driverConfiguration; }
private static Configuration cloneCommandLineConfiguration(final Configuration commandLineConf) throws InjectionException, BindException { final Injector injector = Tang.Factory.getTang().newInjector(commandLineConf); final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder(); cb.bindNamedParameter( NumCycles.class, String.valueOf(injector.getNamedInstance(NumCycles.class))); cb.bindNamedParameter(Delay.class, String.valueOf(injector.getNamedInstance(Delay.class))); cb.bindNamedParameter( SuspendClientControl.Port.class, String.valueOf(injector.getNamedInstance(SuspendClientControl.Port.class))); return cb.build(); }
public static void main(String[] argv) throws IOException, BindException, InjectionException { @SuppressWarnings("unchecked") JavaConfigurationBuilder cb = Tang.Factory.getTang() .newConfigurationBuilder( (Class<? extends ExternalConstructor<?>>[]) new Class[] {FileParser.class}); CommandLine cl = new CommandLine(cb); cl.processCommandLine( argv, Target.class, ClassHierarchyIn.class, ConfigurationIn.class, ConfigurationOut.class); ValidateConfiguration bip = Tang.Factory.getTang().newInjector(cb.build()).getInstance(ValidateConfiguration.class); bip.validatePlan(); }
/** * Parse command line arguments and create TANG configuration ready to be submitted to REEF. * * @param args Command line arguments, as passed into main(). * @return (immutable) TANG Configuration object. * @throws BindException if configuration commandLineInjector fails. * @throws InjectionException if configuration commandLineInjector fails. * @throws IOException error reading the configuration. */ private static Configuration getClientConfiguration(final String[] args) throws BindException, InjectionException, IOException { final Configuration commandLineConf = parseCommandLine(args); final Configuration clientConfiguration = ClientConfiguration.CONF .set(ClientConfiguration.ON_JOB_RUNNING, SuspendClient.RunningJobHandler.class) .set(ClientConfiguration.ON_JOB_FAILED, SuspendClient.FailedJobHandler.class) .set(ClientConfiguration.ON_JOB_COMPLETED, SuspendClient.CompletedJobHandler.class) .set(ClientConfiguration.ON_RUNTIME_ERROR, SuspendClient.RuntimeErrorHandler.class) .build(); final Injector commandLineInjector = Tang.Factory.getTang().newInjector(commandLineConf); final boolean isLocal = commandLineInjector.getNamedInstance(Local.class); final Configuration runtimeConfiguration; if (isLocal) { LOG.log(Level.INFO, "Running on the local runtime"); runtimeConfiguration = LocalRuntimeConfiguration.CONF .set(LocalRuntimeConfiguration.MAX_NUMBER_OF_EVALUATORS, MAX_NUMBER_OF_EVALUATORS) .build(); } else { LOG.log(Level.INFO, "Running on YARN"); runtimeConfiguration = YarnClientConfiguration.CONF.build(); } return Configurations.merge( runtimeConfiguration, clientConfiguration, cloneCommandLineConfiguration(commandLineConf)); }
public void validatePlan() throws IOException, BindException, InjectionException { final Tang t = Tang.Factory.getTang(); // TODO Use the AvroClassHierarchySerializer final ClassHierarchyProto.Node root; try (final InputStream chin = new FileInputStream(this.ch)) { root = ClassHierarchyProto.Node.parseFrom(chin); } final ClassHierarchy classHierarchy = new ProtocolBufferClassHierarchy(root); final ConfigurationBuilder cb = t.newConfigurationBuilder(classHierarchy); if (!inConfig.canRead()) { throw new IOException("Cannot read input config file: " + inConfig); } ConfigurationFile.addConfiguration(cb, inConfig); if (target != null) { final Injector i = t.newInjector(cb.build()); final InjectionPlan<?> ip = i.getInjectionPlan(target); if (!ip.isInjectable()) { throw new InjectionException(target + " is not injectable: " + ip.toCantInjectString()); } } ConfigurationFile.writeConfigurationFile(cb.build(), outConfig); // Injector i = t.newInjector(cb.build()); // InjectionPlan<?> ip = i.getInjectionPlan(target); // try (final OutputStream ipout = new FileOutputStream(injectionPlan)) { // new ProtocolBufferInjectionPlan().serialize(ip).writeTo(ipout); // } }
public static void main(final String[] args) throws InjectionException, IOException { final File localAppSubmissionParametersFile = new File(args[0]); final File jobSubmissionParametersFile = new File(args[1]); if (!(jobSubmissionParametersFile.exists() && jobSubmissionParametersFile.canRead())) { throw new IOException( "Unable to open and read " + jobSubmissionParametersFile.getAbsolutePath()); } if (!(localAppSubmissionParametersFile.exists() && localAppSubmissionParametersFile.canRead())) { throw new IOException( "Unable to open and read " + localAppSubmissionParametersFile.getAbsolutePath()); } final LocalSubmissionFromCS localSubmission = LocalSubmissionFromCS.fromSubmissionParameterFiles( jobSubmissionParametersFile, localAppSubmissionParametersFile); LOG.log(Level.FINE, "Local driver config generation received from C#: {0}", localSubmission); final Configuration localRuntimeConfiguration = localSubmission.getRuntimeConfiguration(); final LocalRuntimeDriverConfigurationGenerator localConfigurationGenerator = Tang.Factory.getTang() .newInjector(localRuntimeConfiguration) .getInstance(LocalRuntimeDriverConfigurationGenerator.class); localConfigurationGenerator.writeConfiguration( localSubmission.getJobFolder(), localSubmission.getJobId(), ClientRemoteIdentifier.NONE); }
/** * NameServer and NameLookupClient test. * * @throws Exception */ @Test public void testNamingLookup() throws Exception { final String localAddress = localAddressProvider.getLocalAddress(); LOG.log(Level.FINEST, this.name.getMethodName()); // names final Map<Identifier, InetSocketAddress> idToAddrMap = new HashMap<Identifier, InetSocketAddress>(); idToAddrMap.put( this.factory.getNewInstance("task1"), new InetSocketAddress(localAddress, 7001)); idToAddrMap.put( this.factory.getNewInstance("task2"), new InetSocketAddress(localAddress, 7002)); // run a server final Injector injector = Tang.Factory.getTang().newInjector(); injector.bindVolatileParameter( NameServerParameters.NameServerIdentifierFactory.class, this.factory); injector.bindVolatileInstance(LocalAddressProvider.class, this.localAddressProvider); try (final NameServer server = injector.getInstance(NameServer.class)) { this.port = server.getPort(); for (final Identifier id : idToAddrMap.keySet()) { server.register(id, idToAddrMap.get(id)); } // run a client try (final NameLookupClient client = new NameLookupClient( localAddress, this.port, 10000, this.factory, RETRY_COUNT, RETRY_TIMEOUT, new NameCache(this.TTL), this.localAddressProvider)) { final Identifier id1 = this.factory.getNewInstance("task1"); final Identifier id2 = this.factory.getNewInstance("task2"); final Map<Identifier, InetSocketAddress> respMap = new HashMap<Identifier, InetSocketAddress>(); InetSocketAddress addr1 = client.lookup(id1); respMap.put(id1, addr1); InetSocketAddress addr2 = client.lookup(id2); respMap.put(id2, addr2); for (final Identifier id : respMap.keySet()) { LOG.log(Level.FINEST, "Mapping: {0} -> {1}", new Object[] {id, respMap.get(id)}); } Assert.assertTrue(isEqual(idToAddrMap, respMap)); } } }
/** * @param args command line arguments, as passed to main() * @return Configuration object. */ private static Configuration parseCommandLine(final String[] args) throws IOException, BindException { final JavaConfigurationBuilder confBuilder = Tang.Factory.getTang().newConfigurationBuilder(); final CommandLine cl = new CommandLine(confBuilder); cl.registerShortNameOfClass(Local.class); cl.registerShortNameOfClass(NumCycles.class); cl.registerShortNameOfClass(Delay.class); cl.registerShortNameOfClass(SuspendClientControl.Port.class); cl.processCommandLine(args); return confBuilder.build(); }
static { try { final Injector injector = Tang.Factory.getTang().newInjector(); RETRY_COUNT = injector.getNamedInstance(NameResolverRetryCount.class); RETRY_TIMEOUT = injector.getNamedInstance(NameResolverRetryTimeout.class); } catch (final InjectionException ex) { final String msg = "Exception while trying to find default values for retryCount & Timeout"; LOG.log(Level.SEVERE, msg, ex); throw new RuntimeException(msg, ex); } }
/** * Main method that runs the example. * * @param args command line parameters. */ public static void main(final String[] args) { try { final Configuration config = getClientConfiguration(args); LOG.log(Level.INFO, "Configuration:\n--\n{0}--", Configurations.toString(config, true)); final Injector injector = Tang.Factory.getTang().newInjector(config); final SuspendClient client = injector.getInstance(SuspendClient.class); client.submit(); client.waitForCompletion(); LOG.info("Done!"); } catch (final BindException | IOException | InjectionException ex) { LOG.log(Level.SEVERE, "Cannot launch: configuration error", ex); } catch (final Exception ex) { LOG.log(Level.SEVERE, "Cleanup error", ex); } }
public static LauncherStatus run( final Class<? extends Task> failTaskClass, final Configuration runtimeConfig, final int timeOut) throws BindException, InjectionException { final Configuration driverConfig = DriverConfiguration.CONF .set( DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(Driver.class)) .set(DriverConfiguration.DRIVER_IDENTIFIER, failTaskClass.getSimpleName()) .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, Driver.AllocatedEvaluatorHandler.class) .set(DriverConfiguration.ON_TASK_RUNNING, Driver.RunningTaskHandler.class) .set(DriverConfiguration.ON_CONTEXT_ACTIVE, Driver.ActiveContextHandler.class) .set(DriverConfiguration.ON_DRIVER_STARTED, Driver.StartHandler.class) .build(); final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder(); cb.addConfiguration(driverConfig); cb.bindNamedParameter(Driver.FailTaskName.class, failTaskClass.getSimpleName()); return TestDriverLauncher.getLauncher(runtimeConfig).run(cb.build(), timeOut); }
public NamingTest() throws InjectionException { this.localAddressProvider = Tang.Factory.getTang().newInjector().getInstance(LocalAddressProvider.class); }
/** * Test concurrent lookups (threads share a client). * * @throws Exception */ @Test public void testConcurrentNamingLookup() throws Exception { LOG.log(Level.FINEST, this.name.getMethodName()); final String localAddress = localAddressProvider.getLocalAddress(); // test it 3 times to make failure likely for (int i = 0; i < 3; i++) { LOG.log(Level.FINEST, "test {0}", i); // names final Map<Identifier, InetSocketAddress> idToAddrMap = new HashMap<Identifier, InetSocketAddress>(); idToAddrMap.put( this.factory.getNewInstance("task1"), new InetSocketAddress(localAddress, 7001)); idToAddrMap.put( this.factory.getNewInstance("task2"), new InetSocketAddress(localAddress, 7002)); idToAddrMap.put( this.factory.getNewInstance("task3"), new InetSocketAddress(localAddress, 7003)); // run a server final Injector injector = Tang.Factory.getTang().newInjector(); injector.bindVolatileParameter( NameServerParameters.NameServerIdentifierFactory.class, this.factory); injector.bindVolatileInstance(LocalAddressProvider.class, this.localAddressProvider); try (final NameServer server = injector.getInstance(NameServer.class)) { this.port = server.getPort(); for (final Identifier id : idToAddrMap.keySet()) { server.register(id, idToAddrMap.get(id)); } // run a client try (final NameLookupClient client = new NameLookupClient( localAddress, this.port, 10000, this.factory, RETRY_COUNT, RETRY_TIMEOUT, new NameCache(this.TTL), this.localAddressProvider)) { final Identifier id1 = this.factory.getNewInstance("task1"); final Identifier id2 = this.factory.getNewInstance("task2"); final Identifier id3 = this.factory.getNewInstance("task3"); final ExecutorService e = Executors.newCachedThreadPool(); final ConcurrentMap<Identifier, InetSocketAddress> respMap = new ConcurrentHashMap<Identifier, InetSocketAddress>(); final Future<?> f1 = e.submit( new Runnable() { @Override public void run() { InetSocketAddress addr = null; try { addr = client.lookup(id1); } catch (final Exception e) { LOG.log(Level.SEVERE, "Lookup failed", e); Assert.fail(e.toString()); } respMap.put(id1, addr); } }); final Future<?> f2 = e.submit( new Runnable() { @Override public void run() { InetSocketAddress addr = null; try { addr = client.lookup(id2); } catch (final Exception e) { LOG.log(Level.SEVERE, "Lookup failed", e); Assert.fail(e.toString()); } respMap.put(id2, addr); } }); final Future<?> f3 = e.submit( new Runnable() { @Override public void run() { InetSocketAddress addr = null; try { addr = client.lookup(id3); } catch (final Exception e) { LOG.log(Level.SEVERE, "Lookup failed", e); Assert.fail(e.toString()); } respMap.put(id3, addr); } }); f1.get(); f2.get(); f3.get(); for (final Identifier id : respMap.keySet()) { LOG.log(Level.FINEST, "Mapping: {0} -> {1}", new Object[] {id, respMap.get(id)}); } Assert.assertTrue(isEqual(idToAddrMap, respMap)); } } } }
@SuppressWarnings("unchecked") public Tint(final URL[] jars, final boolean checkTang) { final Object[] args = new Object[jars.length + 6]; for (int i = 0; i < jars.length; i++) { args[i] = jars[i]; } args[args.length - 1] = new TypeAnnotationsScanner(); args[args.length - 2] = new SubTypesScanner(); args[args.length - 3] = new MethodAnnotationsScanner(); args[args.length - 4] = new MethodParameterScanner(); args[args.length - 5] = "com.microsoft"; args[args.length - 6] = "org.apache"; final Reflections r = new Reflections(args); // Set<Class<?>> classes = new MonotonicSet<>(); final Set<String> strings = new TreeSet<>(); final Set<String> moduleBuilders = new MonotonicSet<>(); // Workaround bug in Reflections by keeping things stringly typed, and using Tang to parse them. // Set<Constructor<?>> injectConstructors = // (Set<Constructor<?>>)(Set)r.getMethodsAnnotatedWith(Inject.class); // for(Constructor<?> c : injectConstructors) { // classes.add(c.getDeclaringClass()); // } final Set<String> injectConstructors = r.getStore().getConstructorsAnnotatedWith(ReflectionUtilities.getFullName(Inject.class)); for (final String s : injectConstructors) { strings.add(s.replaceAll("\\.<.+$", "")); } final Set<String> parameterConstructors = r.getStore() .get(MethodParameterScanner.class, ReflectionUtilities.getFullName(Parameter.class)); for (final String s : parameterConstructors) { strings.add(s.replaceAll("\\.<.+$", "")); } // Set<Class> r.getConstructorsWithAnyParamAnnotated(Parameter.class); // for(Constructor<?> c : parameterConstructors) { // classes.add(c.getDeclaringClass()); // } final Set<String> defaultStrings = r.getStore() .get( TypeAnnotationsScanner.class, ReflectionUtilities.getFullName(DefaultImplementation.class)); strings.addAll(defaultStrings); strings.addAll( r.getStore() .get( TypeAnnotationsScanner.class, ReflectionUtilities.getFullName(NamedParameter.class))); strings.addAll( r.getStore() .get(TypeAnnotationsScanner.class, ReflectionUtilities.getFullName(Unit.class))); // classes.addAll(r.getTypesAnnotatedWith(DefaultImplementation.class)); // classes.addAll(r.getTypesAnnotatedWith(NamedParameter.class)); // classes.addAll(r.getTypesAnnotatedWith(Unit.class)); strings.addAll( r.getStore().get(SubTypesScanner.class, ReflectionUtilities.getFullName(Name.class))); moduleBuilders.addAll( r.getStore() .get( SubTypesScanner.class, ReflectionUtilities.getFullName(ConfigurationModuleBuilder.class))); // classes.addAll(r.getSubTypesOf(Name.class)); ch = Tang.Factory.getTang() .getDefaultClassHierarchy( jars, (Class<? extends ExternalConstructor<?>>[]) new Class[0]); // for(String s : defaultStrings) { // if(classFilter(checkTang, s)) { // try { // ch.getNode(s); // } catch(ClassHierarchyException | NameResolutionException | ClassNotFoundException e) // { // System.err.println(e.getMessage()); // } // } // } for (final String s : strings) { if (classFilter(checkTang, s)) { try { ch.getNode(s); } catch (ClassHierarchyException | NameResolutionException e) { System.err.println(e.getMessage()); } } } for (final String s : moduleBuilders) { if (classFilter(checkTang, s)) { try { ch.getNode(s); } catch (ClassHierarchyException | NameResolutionException e) { e.printStackTrace(); } } } final NodeVisitor<Node> v = new AbstractClassHierarchyNodeVisitor() { @Override public boolean visit(final NamedParameterNode<?> node) { final String nodeS = node.getFullName(); for (final String s : node.getDefaultInstanceAsStrings()) { if (!usages.contains(s, nodeS)) { usages.put(s, nodeS); } } return true; } @Override public boolean visit(final PackageNode node) { return true; } @Override public boolean visit(final ClassNode<?> node) { final String nodeS = node.getFullName(); for (final ConstructorDef<?> d : node.getInjectableConstructors()) { for (final ConstructorArg a : d.getArgs()) { if (a.getNamedParameterName() != null && !usages.contains(a.getNamedParameterName(), nodeS)) { usages.put(a.getNamedParameterName(), nodeS); } } } if (!knownClasses.contains(node)) { knownClasses.add(node); } return true; } }; int numClasses; do { numClasses = knownClasses.size(); Walk.preorder(v, null, ch.getNamespace()); for (final ClassNode<?> cn : knownClasses) { try { final String s = cn.getFullName(); if (classFilter(checkTang, s)) { final Class<?> c = ch.classForName(s); processDefaultAnnotation(c); processConfigurationModules(c); } } catch (final ClassNotFoundException e) { e.printStackTrace(); } } for (final Entry<Field, ConfigurationModule> entry : modules.entrySet()) { final String fS = ReflectionUtilities.getFullName(entry.getKey()); final Set<NamedParameterNode<?>> nps = entry.getValue().getBoundNamedParameters(); for (final NamedParameterNode<?> np : nps) { final String npS = np.getFullName(); if (!setters.contains(npS, fS)) { setters.put(npS, fS); } } } } while (numClasses != knownClasses .size()); // Note naive fixed point evaluation here. Semi-naive would be faster. }
/** * NameServer and NameRegistryClient test. * * @throws Exception */ @Test public void testNamingRegistry() throws Exception { LOG.log(Level.FINEST, this.name.getMethodName()); final Injector injector = Tang.Factory.getTang().newInjector(); injector.bindVolatileParameter( NameServerParameters.NameServerIdentifierFactory.class, this.factory); injector.bindVolatileInstance(LocalAddressProvider.class, this.localAddressProvider); try (final NameServer server = injector.getInstance(NameServer.class)) { this.port = server.getPort(); final String localAddress = localAddressProvider.getLocalAddress(); // names to start with final Map<Identifier, InetSocketAddress> idToAddrMap = new HashMap<Identifier, InetSocketAddress>(); idToAddrMap.put( this.factory.getNewInstance("task1"), new InetSocketAddress(localAddress, 7001)); idToAddrMap.put( this.factory.getNewInstance("task2"), new InetSocketAddress(localAddress, 7002)); // registration // invoke registration from the client side try (final NameRegistryClient client = new NameRegistryClient( localAddress, this.port, this.factory, this.localAddressProvider)) { for (final Identifier id : idToAddrMap.keySet()) { client.register(id, idToAddrMap.get(id)); } // wait final Set<Identifier> ids = idToAddrMap.keySet(); busyWait(server, ids.size(), ids); // check the server side Map<Identifier, InetSocketAddress> serverMap = new HashMap<Identifier, InetSocketAddress>(); Iterable<NameAssignment> nas = server.lookup(ids); for (final NameAssignment na : nas) { LOG.log( Level.FINEST, "Mapping: {0} -> {1}", new Object[] {na.getIdentifier(), na.getAddress()}); serverMap.put(na.getIdentifier(), na.getAddress()); } Assert.assertTrue(isEqual(idToAddrMap, serverMap)); // un-registration for (final Identifier id : idToAddrMap.keySet()) { client.unregister(id); } // wait busyWait(server, 0, ids); serverMap = new HashMap<Identifier, InetSocketAddress>(); nas = server.lookup(ids); for (final NameAssignment na : nas) { serverMap.put(na.getIdentifier(), na.getAddress()); } Assert.assertEquals(0, serverMap.size()); } } }
/** * NameServer and NameClient test. * * @throws Exception */ @Test public void testNameClient() throws Exception { LOG.log(Level.FINEST, this.name.getMethodName()); final String localAddress = localAddressProvider.getLocalAddress(); final Injector injector = Tang.Factory.getTang().newInjector(); injector.bindVolatileParameter( NameServerParameters.NameServerIdentifierFactory.class, this.factory); injector.bindVolatileInstance(LocalAddressProvider.class, this.localAddressProvider); try (final NameServer server = injector.getInstance(NameServer.class)) { this.port = server.getPort(); final Map<Identifier, InetSocketAddress> idToAddrMap = new HashMap<Identifier, InetSocketAddress>(); idToAddrMap.put( this.factory.getNewInstance("task1"), new InetSocketAddress(localAddress, 7001)); idToAddrMap.put( this.factory.getNewInstance("task2"), new InetSocketAddress(localAddress, 7002)); // registration // invoke registration from the client side Configuration nameResolverConf = NameResolverConfiguration.CONF .set(NameResolverConfiguration.NAME_SERVER_HOSTNAME, localAddress) .set(NameResolverConfiguration.NAME_SERVICE_PORT, this.port) .set(NameResolverConfiguration.CACHE_TIMEOUT, this.TTL) .set(NameResolverConfiguration.RETRY_TIMEOUT, RETRY_TIMEOUT) .set(NameResolverConfiguration.RETRY_COUNT, RETRY_COUNT) .build(); try (final NameResolver client = Tang.Factory.getTang().newInjector(nameResolverConf).getInstance(NameClient.class)) { for (final Identifier id : idToAddrMap.keySet()) { client.register(id, idToAddrMap.get(id)); } // wait final Set<Identifier> ids = idToAddrMap.keySet(); busyWait(server, ids.size(), ids); // lookup final Identifier id1 = this.factory.getNewInstance("task1"); final Identifier id2 = this.factory.getNewInstance("task2"); final Map<Identifier, InetSocketAddress> respMap = new HashMap<Identifier, InetSocketAddress>(); InetSocketAddress addr1 = client.lookup(id1); respMap.put(id1, addr1); InetSocketAddress addr2 = client.lookup(id2); respMap.put(id2, addr2); for (final Identifier id : respMap.keySet()) { LOG.log(Level.FINEST, "Mapping: {0} -> {1}", new Object[] {id, respMap.get(id)}); } Assert.assertTrue(isEqual(idToAddrMap, respMap)); // un-registration for (final Identifier id : idToAddrMap.keySet()) { client.unregister(id); } // wait busyWait(server, 0, ids); final Map<Identifier, InetSocketAddress> serverMap = new HashMap<Identifier, InetSocketAddress>(); addr1 = server.lookup(id1); if (addr1 != null) { serverMap.put(id1, addr1); } addr2 = server.lookup(id1); if (addr2 != null) { serverMap.put(id2, addr2); } Assert.assertEquals(0, serverMap.size()); } } }