Examples of LookupDiscoveryManager


Examples of net.jini.discovery.LookupDiscoveryManager

      leaseList = new Vector();
      creatorListener = new ServiceCreatorListener();
      destroyListener = new JobDestroyListener();
      ServiceItem si;
      ServiceTemplate st;
      LookupDiscoveryManager discovery = new
        LookupDiscoveryManager(spaceGroups, locators, null);
      ServiceDiscoveryManager serviceDiscoveryManager = new
        ServiceDiscoveryManager(discovery, null);
      System.out.print("...");
      st = new ServiceTemplate(null, spaceClss, spaceEntries);
      si = serviceDiscoveryManager.lookup(st, null,
                                          10 * 1000);
      if(si != null && si.service != null) {
        space = (JavaSpace) si.service;
        si = null;
        System.out.print("...");
      } else {
        throw
          new RMServerException("JobRepository not found");
      }
      discovery.setGroups(txnGroups);
      st = new ServiceTemplate(txnID, txnClss, txnEntries);
      si = serviceDiscoveryManager.lookup(st, null,
                                          10 * 1000);
      if(si != null && si.service != null) {
        txnMgr = (TransactionManager) si.service;
        si = null;
        System.out.print("...");
      } else {
        throw
          new RMServerException("TransactionManager not found");
      }
      discovery.terminate();
      serviceDiscoveryManager.terminate();
      System.out.println(" ready.");
    } catch(Exception e) {
      throw new RMServerException(e.getMessage());
    }
View Full Code Here

Examples of net.jini.discovery.LookupDiscoveryManager

  {
    try {
      // Due to a bug in Jini 1.1 Alpha, it's best to start off with NO_GROUPS
      // LookupDiscovery construction, and add the groups specification
      // after the JoinManager has been constructed.
      discovery = new LookupDiscoveryManager(LookupDiscovery.NO_GROUPS,
               locators, null);

      proxy.setServerRef(this);
      myJM = new JoinManager(proxy, attrs, this, discovery,
                                       null);
View Full Code Here

Examples of net.jini.discovery.LookupDiscoveryManager

  public JAMServiceUILauncher(String[] groups, LookupLocator[] locators,
                              Entry[] entry, String clName)
    throws ClassNotFoundException, IOException
  {
    super();
    clm = new ServiceDiscoveryManager(new
      LookupDiscoveryManager(groups, locators, null), null);
    Class [] cls = { Class.forName(clName) };
    lookupCache = clm.createLookupCache(new
      ServiceTemplate(null, cls, entry), null, this);
    //this.key = ((JobUserKey)entry[0]).key;
View Full Code Here

Examples of net.jini.discovery.LookupDiscoveryManager

                                  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

Examples of net.jini.discovery.LookupDiscoveryManager

        GroupsUtil.displayGroupSet(groupsToJoin,
                                   "groupsToDiscoverAndJoin",Level.FINE);
        LocatorsUtil.displayLocatorSet(locsToJoin,
                                      "locsToDiscoverAndJoin",Level.FINE);
  try {
      return new LookupDiscoveryManager(groupsToJoin,
                locsToJoin,
                mainListener,
                getConfig().getConfiguration());
  } catch (ConfigurationException e) {
      throw new RuntimeException("Configuration Error", e);
View Full Code Here

Examples of net.jini.discovery.LookupDiscoveryManager

        GroupsUtil.displayGroupSet(groupsToJoin,
                                   "groupsToDiscoverAndJoin",Level.FINE);
        LocatorsUtil.displayLocatorSet(locsToJoin,
                                      "locsToDiscoverAndJoin",Level.FINE);
  try {
      return new LookupDiscoveryManager(groupsToJoin,
                locsToJoin,
                mainListener,
                config.getConfiguration());
  } catch (ConfigurationException e) {
      throw new RuntimeException("Configuration Error", e);
View Full Code Here

Examples of net.jini.discovery.LookupDiscoveryManager

        super.setup(sysConfig);
        testDesc = "NullPointerException should occur upon adding a null "
                   +"listener to a lookup cache";
        logger.log(Level.FINE, "constructing a service discovery manager");
        discoveryMgr =
      new LookupDiscoveryManager(DiscoveryGroupManagement.NO_GROUPS,
               null,
               null,
               sysConfig.getConfiguration());
        srvcDiscoveryMgr =
      new ServiceDiscoveryManager(discoveryMgr,
View Full Code Here

Examples of net.jini.discovery.LookupDiscoveryManager

         * 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

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

Examples of net.jini.discovery.LookupDiscoveryManager

  }
  try {
      discoer = (DiscoveryManagement) config.getEntry(
    COMPONENT, "discoveryManager", DiscoveryManagement.class);
  } catch (NoSuchEntryException e) {
      discoer = new LookupDiscoveryManager(
    DiscoveryGroupManagement.NO_GROUPS, null, null, config);
  }
  listenerPreparer = (ProxyPreparer) Config.getNonNullEntry(
      config, COMPONENT, "listenerPreparer", ProxyPreparer.class,
      listenerPreparer);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.