public void end() throws IOException { synchronized (this) { if (ended) { return; } ended = true; } try { registry.leave(); } catch (Throwable e) { throw new IbisIOException("Registry: leave failed ", e); } if (managementClient != null) { managementClient.end(); } if (vivaldiClient != null) { vivaldiClient.end(); } quit(); }
/** @ibis.experimental */ public String[] wonElections() { return registry.wonElections(); }
/** * Constructs an <code>Ibis</code> instance with the specified parameters. * * @param registryHandler the registryHandler. * @param capabilities the capabilities. * @param applicationTag an application level tag for this Ibis instance * @param portTypes the port types requested for this ibis implementation. * @param userProperties the properties as provided by the Ibis factory. */ protected Ibis( RegistryEventHandler registryHandler, IbisCapabilities capabilities, Credentials credentials, byte[] applicationTag, PortType[] portTypes, Properties userProperties, IbisStarter starter) throws IbisCreationFailedException { if (capabilities == null) { throw new IbisConfigurationException("capabilities not specified"); } this.capabilities = capabilities; this.portTypes = portTypes; this.starter = starter; this.properties = new TypedProperties(); // bottom up add properties, starting with hard coded ones properties.addProperties(IbisProperties.getHardcodedProperties()); properties.addProperties(userProperties); // set unique ID for this Ibis. properties.setProperty(ID_PROPERTY, UUID.randomUUID().toString()); if (logger.isDebugEnabled()) { logger.debug("Ibis constructor: properties = " + properties); } receivePorts = new HashMap<String, ReceivePort>(); sendPorts = new HashMap<String, SendPort>(); if (registryHandler != null) { // Only install wrapper if user actually has an event handler. // Otherwise, registry downcalls won't work. There needs to be another // way to let an Ibis know of died Ibises. --Ceriel registryHandler = new RegistryEventHandlerWrapper(registryHandler, this); } try { registry = Registry.createRegistry( this.capabilities, registryHandler, properties, getData(), getImplementationVersion(), applicationTag, credentials); } catch (IbisConfigurationException e) { throw e; } catch (Throwable e) { throw new IbisCreationFailedException("Could not create registry", e); } ident = registry.getIbisIdentifier(); if (properties.getBooleanProperty("ibis.vivaldi")) { try { vivaldiClient = new VivaldiClient(properties, registry); } catch (Exception e) { throw new IbisCreationFailedException("Could not create vivaldi client", e); } } else { vivaldiClient = null; } if (properties.getBooleanProperty("ibis.bytescount")) { sentBytesPerIbis = new HashMap<ibis.ipl.IbisIdentifier, Long>(); receivedBytesPerIbis = new HashMap<ibis.ipl.IbisIdentifier, Long>(); } if (properties.getBooleanProperty("ibis.managementclient")) { try { managementClient = new ManagementClient(properties, this); } catch (Throwable e) { throw new IbisCreationFailedException("Could not create management client", e); } } else { managementClient = null; } /* * // add bean to JMX try { MBeanServer mbs = * ManagementFactory.getPlatformMBeanServer(); ObjectName name = new * ObjectName("ibis.ipl.impl:type=Ibis"); mbs.registerMBean(this, name); * } catch (Exception e) { logger.warn("cannot registry MBean", e); } */ }