Package net.jini.discovery

Examples of net.jini.discovery.LookupDiscoveryManager


     
      ((DiscoveryGroupManagement)lookupDiscMgr).setGroups(lookupGroups);
      ((DiscoveryLocatorManagement)lookupDiscMgr).setLocators(lookupLocators);
  } catch (NoSuchEntryException e) {
      lookupDiscMgr  =
    new LookupDiscoveryManager(lookupGroups, lookupLocators,
                    null, config);
  }
        if (initLogger.isLoggable(Level.FINEST)) {
            initLogger.log(Level.FINEST, "Discovery manager is: {0}",
      lookupDiscMgr);
View Full Code Here


      {
    throw new ConfigurationException(
            "discoveryManager cannot have initial locators");
      }
  } catch (NoSuchEntryException e) {
      disco = new LookupDiscoveryManager(new String[0],
                 new LookupLocator[0], null,
                 config);
  }
  disco.setGroups((String[]) config.getEntry(BROWSER,
               "initialLookupGroups",
View Full Code Here

          + serviceName + ".impl",
            e);
  }
  eventList = new LinkedList(); // every start call gets a new list
  DiscoveryListener listener = new RunningDiscoveryListener();
  LookupDiscoveryManager manager = null;
  // populate the groups/locators arrays. Discard the overrides list.
  // This admin implement doRandom to return false to inhibit
  // randomization of the group names
  addServiceGroupsAndLocators(new ArrayList());
  try {
      manager = new LookupDiscoveryManager(getGroups(),
             getLocators(),
             listener);
  } catch (IOException e) {
      throw new TestException("failed to create a LookupDiscoveryManager",
            e);
  }
  logServiceParameters();
  ServiceTemplate template = new ServiceTemplate(null, types, null);
  while (true) {
      DiscoveryEvent event = null;
      synchronized (eventList) {
    try {
        event = (DiscoveryEvent) eventList.removeFirst();
    } catch (NoSuchElementException e) {
        try {
      eventList.wait(); // XXX timeout?
        } catch (InterruptedException ie) {
        }
    }
      }
      if (event != null) {
    ServiceRegistrar[] registrars = event.getRegistrars();
    for (int i = registrars.length; --i >= 0; ) {
        ServiceRegistrar registrar = registrars[i];
        serviceRef = registrar.lookup(template);
        if (serviceRef != null) {
      manager.terminate();
      return;             
        }
    }
      }
  }       
View Full Code Here

      {
    throw new ConfigurationException(
            "discoveryManager cannot have initial locators");
      }
  } catch (NoSuchEntryException e) {
      disco = new LookupDiscoveryManager(new String[0],
                 new LookupLocator[0], null,
                 config);
  }
  disco.setGroups((String[]) config.getEntry(BROWSER,
               "initialLookupGroups",
View Full Code Here

  }
//TODO - defer creation of default LDM
  dm = (DiscoveryManagement)
      Config.getNonNullEntry(config, TxnManager.MAHALO,
    "discoveryManager", DiscoveryManagement.class,
    new LookupDiscoveryManager(
                    DiscoveryGroupManagement.NO_GROUPS, null, null, config));
        if(initlogger.isLoggable(Level.CONFIG)) {
      initlogger.log(Level.CONFIG, "discoveryManager: {0}", dm);
  }
View Full Code Here

        "locators");
      }
      ((DiscoveryGroupManagement) dm).setGroups(groups);
      ((DiscoveryLocatorManagement) dm).setLocators(locators);
  } catch (NoSuchEntryException e) {
      dm = new LookupDiscoveryManager(groups, locators, null, config);
  }
    }
View Full Code Here

                logger.log(Levels.HANDLED,
                           " TestService-"+val+": lease duration = "
                           +renewDur);
            }//endif

            ldm = new LookupDiscoveryManager(groupsToJoin, locatorsToJoin,
                                             null, config);

            ServerEndpoint endpoint = TcpServerEndpoint.getInstance(0);
            InvocationLayerFactory ilFactory = new BasicILFactory();
            Exporter defaultExporter = new BasicJeriExporter(endpoint,
View Full Code Here

         * and DiscoveryLocatorManagement, and should be initially configured
         * to discover NO_GROUPS and NO LOCATORS. This discovery manager is
         * retrieved from the configuration after recovery of any persistent
         * state, and after retrieval of any initial configuration items.
         */
        discoveryMgr = new LookupDiscoveryManager
                                          (DiscoveryGroupManagement.NO_GROUPS,
                                           new LookupLocator[0],
                                           null,
                                           config);

        /* Get the proxy preparers for the remote event listeners */
        listenerPreparer = (ProxyPreparer)Config.getNonNullEntry
                                                   (config,
                                                    COMPONENT_NAME,
                                                    "listenerPreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
        /* Get the proxy preparers for the lookup locators to join */
        locatorToJoinPreparer = (ProxyPreparer)Config.getNonNullEntry
                                                   (config,
                                                    COMPONENT_NAME,
                                                    "locatorToJoinPreparer",
                                                    ProxyPreparer.class,
                                                    new BasicProxyPreparer());
        /* Get the proxy preparers for the lookup locators to discover */
        locatorToDiscoverPreparer = (ProxyPreparer)Config.getNonNullEntry
                                                 (config,
                                                  COMPONENT_NAME,
                                                  "locatorToDiscoverPreparer",
                                                  ProxyPreparer.class,
                                                  new BasicProxyPreparer());
        if(persistent) {
            /* Retrieve the proxy preparers that will only be applied during
             * the state recovery process below, when any previously stored
             * listeners or locators are recovered from persistent storage.
             */
            recoveredListenerPreparer =
             (ProxyPreparer)Config.getNonNullEntry(config,
                                                   COMPONENT_NAME,
                                                   "recoveredListenerPreparer",
                                                   ProxyPreparer.class,
                                                   new BasicProxyPreparer());
            recoveredLocatorToJoinPreparer =
             (ProxyPreparer)Config.getNonNullEntry
                                             (config,
                                              COMPONENT_NAME,
                                              "recoveredLocatorToJoinPreparer",
                                              ProxyPreparer.class,
                                              new BasicProxyPreparer());
            recoveredLocatorToDiscoverPreparer =
             (ProxyPreparer)Config.getNonNullEntry
                                         (config,
                                          COMPONENT_NAME,
                                          "recoveredLocatorToDiscoverPreparer",
                                          ProxyPreparer.class,
                                          new BasicProxyPreparer());


            /* Get the log directory for persisting this service's state */
            persistDir = (String)Config.getNonNullEntry(config,
                                                        COMPONENT_NAME,
                                                        "persistenceDirectory",
                                                        String.class);
            /* Recover the state that was persisted on prior runs (if any) */
            log = new ReliableLog(persistDir, new LocalLogHandler());
            inRecovery = true;
            log.recover();
            inRecovery = false;
        }//endif(persistent)

        /* For the two persistent versions of this service (activatable and
         * non-activatable), state recovery is complete. For the non-persistent
         * version of this service, no state recovery occurred (because it
         * wasn't necessary).
         *
         * For the two persistent versions, there is a circumstance in which
         * 'one time', initial items must be retrieved from the configuration:
         * when the service is started for the very first time. For the
         * non-persistent version, those items will be retrieved every time
         * the service is started.
         *
         * The flag 'initialStartup' is used below to determine whether
         * or not to retrieve the initial configuration items. This is the
         * only purpose for that flag.
         *
         * For either persistent version of the service, the flag's value
         * will be changed to false during the startup process only when
         * there already exists a 'snapshot' of the service's state from
         * a previous run. This is because the flag's value is only
         * changed during the recovery of the snapshot (see the method
         * recoverSnapshot()). Note that the only time such a snapshot
         * should NOT already exist at startup, is when the service is
         * being started for the very first time. Thus, when either
         * persistent version of the service is started for the first
         * time, the service's configuration is consulted for the initial
         * values of the items below; otherwise, when the service is being
         * re-started (after a crash for example), the values used for
         * those items will be the values retrieved above during recovery
         * of the service's persistent state.
         *
         * With respect to the non-persistent version of the service, the
         * values of the items below will always be retrieved at startup.
         * This is because the non-persistent version of the service never
         * attempts to recover previously stored state; thus, the flag's
         * value will never change. Note that this will be true even if a
         * snapshot exists from a previous run of one of the persistent
         * versions of the service.
         *
         * The service's Uuid is also handled here.
         */
        if(initialStartup) {
            if(log != null) {
                snapshotWt = ((Float)config.getEntry
                                         (COMPONENT_NAME,
                                          "initialPersistenceSnapshotWeight",
                                          float.class,
                                          new Float(snapshotWt))).floatValue();
                snapshotThresh =
                       Config.getIntEntry
                                  (config,
                                   COMPONENT_NAME,
                                   "initialPersistenceSnapshotThreshold",
                                   snapshotThresh, 0, Integer.MAX_VALUE);
            }//endif(log != null)
            leaseBound = Config.getLongEntry(config,
                                             COMPONENT_NAME,
                                             "initialLeaseBound",
                                             leaseBound, 0, Long.MAX_VALUE);
            /* Get any additional attributes with which to associate this
             * service when registering it with any lookup services.
             */
            Entry[] initAttrs = (Entry[])config.getEntry
                                                   (COMPONENT_NAME,
                                                    "initialLookupAttributes",
                                                    Entry[].class,
                                                    null );
            if(initAttrs != null) {
                ArrayList attrsList
                   = new ArrayList(thisServicesAttrs.length+initAttrs.length);
                for(int i=0;i<thisServicesAttrs.length;i++) {
                    attrsList.add(thisServicesAttrs[i]);
                }//end loop
                for(int i=0;i<initAttrs.length;i++) {
                    attrsList.add(initAttrs[i]);
                }//end loop
                thisServicesAttrs = (Entry[])attrsList.toArray
                                                (new Entry[attrsList.size()]);
            }//endif(initAttrs != null)

            /* Get the initial groups this service should join. */
            thisServicesGroups =
                 (String[])config.getEntry(COMPONENT_NAME,
                                           "initialLookupGroups",
                                           String[].class,
                                           thisServicesGroups);
            /* Get the initial locators this service should join. */
            thisServicesLocators =
                     (LookupLocator[])config.getEntry(COMPONENT_NAME,
                                                      "initialLookupLocators",
                                                      LookupLocator[].class,
                                                      new LookupLocator[0]);
            if(thisServicesLocators == null) {
                thisServicesLocators = new LookupLocator[0];
            }//endif

            /* Generate the private, universally unique (over space and time)
             * ID that will be used by the outer proxy to test for equality
             * with other proxies.
             */
            proxyID = UuidFactory.generate();
        }//endif(initialStartup)

        /* The proxyID should never be null at this point. It should have
         * been either recovered from the persisted state, or generated above.
         */
        if(proxyID == null) throw new NullPointerException("proxyID == null");

        /* Get the various configurable constants */
        leaseMax = Config.getLongEntry(config,
                                       COMPONENT_NAME,
                                       "leaseMax",
                                       leaseMax, 0, Long.MAX_VALUE);
        /* Take a snapshot of the current state to "clean up" the log file,
         * and to record the items set above.
         */
  if(log != null) log.snapshot();
        /* The service ID used to register this service with lookup services
         * is always derived from the proxyID that is associated with the
         * service for the lifetime of the service.
         */
        serviceID = new ServiceID(proxyID.getMostSignificantBits(),
                                  proxyID.getLeastSignificantBits());
        /* Get a general-purpose task manager for this service */
        taskMgr = (TaskManager)Config.getNonNullEntry
                                          (config,
                                           COMPONENT_NAME,
                                           "taskManager",
                                           TaskManager.class,
                                           new TaskManager(10,1000*15,1.0f) );
        /* Get the discovery manager to pass to this service's join manager. */
        try {
            joinMgrLDM  =
                (DiscoveryManagement)Config.getNonNullEntry
                                                  (config,
                                                   COMPONENT_NAME,
                                                   "discoveryManager",
                                                   DiscoveryManagement.class);
            if( joinMgrLDM instanceof DiscoveryGroupManagement ) {
                String[] groups0 =
                           ((DiscoveryGroupManagement)joinMgrLDM).getGroups();
                if(    (groups0 == DiscoveryGroupManagement.ALL_GROUPS)
                    || (groups0.length != 0) )
                {
                    throw new ConfigurationException
                                 ("discoveryManager entry must be configured "
                                  +"to initially discover/join NO_GROUPS");
                }//endif
            } else {// !(joinMgrLDM instanceof DiscoveryGroupManagement)
                throw new ConfigurationException
                                       ("discoveryManager entry must "
                                        +"implement DiscoveryGroupManagement");
            }//endif
            if( joinMgrLDM instanceof DiscoveryLocatorManagement ) {
                LookupLocator[] locs0 =
                        ((DiscoveryLocatorManagement)joinMgrLDM).getLocators();
                if( (locs0 != null) && (locs0.length != 0) ) {
                    throw new ConfigurationException
                                 ("discoveryManager entry must be configured "
                                  +"to initially discover/join no locators");
                }//endif
            } else {// !(joinMgrLDM instanceof DiscoveryLocatorManagement)
                throw new ConfigurationException
                                     ("discoveryManager entry must "
                                      +"implement DiscoveryLocatorManagement");
            }//endif
        } catch (NoSuchEntryException e) {
            joinMgrLDM
               = new LookupDiscoveryManager(DiscoveryGroupManagement.NO_GROUPS,
                                            new LookupLocator[0], null,config);
        }

        /* Handle items and duties related to exporting this service. */
        ServerEndpoint endpoint = TcpServerEndpoint.getInstance(0);
View Full Code Here

                                  Level.FINE);
        LookupLocator[] locsToDiscover = toLocatorArray(initLookupsToStart);
        LocatorsUtil.displayLocatorSet(locsToDiscover,"  locsToDiscover",
                                       Level.FINE);
  try {
      return new LookupDiscoveryManager(groupsToDiscover,
                locsToDiscover,
                mainListener,
                getConfig().getConfiguration());
  } catch (ConfigurationException e) {
      throw new RuntimeException("Configuration Error", e);
View Full Code Here

       "creating a lookup discovery manager "
       +"initially configured to discover NO_GROUPS "
       +"and NO_LOCATORS");
  /* discover no groups at first, wait for test to call setGroups */
  discoveryMgr =
      new LookupDiscoveryManager(DiscoveryGroupManagement.NO_GROUPS,
               new LookupLocator[0],
               null,
               config.getConfiguration());
  ldmList.add(discoveryMgr);
  mainListener = new LookupListener();
View Full Code Here

TOP

Related Classes of net.jini.discovery.LookupDiscoveryManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.