Package net.jini.core.lookup

Examples of net.jini.core.lookup.ServiceRegistrar


                 */
                Set eSet = discoveredMap.entrySet();
          Iterator iter = eSet.iterator();
                while(iter.hasNext()) {
                    Map.Entry pair = (Map.Entry)iter.next();
                    ServiceRegistrar srvcReg = (ServiceRegistrar)pair.getKey();
                    String[] srvcRegGroups   = (String[])pair.getValue();
                    boolean inSet = inToDiscoverSet(srvcReg,srvcRegGroups);
                    if( inToDiscoverSet(srvcReg,srvcRegGroups) ) continue;
                    expectedDiscoveredMap.remove(srvcReg);
                    expectedNoInterestDiscardedMap.put(srvcReg,srvcRegGroups);
                    expectedPassiveDiscardedMap.put(srvcReg,srvcRegGroups);
                }//end loop
                /* If one of the registrars that's already been DISCARDED
                 * belongs to any of the groups to discover and/or has a
                 * locator that's an element of the set of locators to
                 * discover, MOVE that registrar's corresponding element from
                 * the discardedMap into the expectedDiscoveredMap.
                 */
                eSet = discardedMap.entrySet();
          iter = eSet.iterator();
                while(iter.hasNext()) {
                    Map.Entry pair = (Map.Entry)iter.next();
                    ServiceRegistrar srvcReg = (ServiceRegistrar)pair.getKey();
                    String[] srvcRegGroups   = (String[])pair.getValue();
                    if( !inToDiscoverSet(srvcReg,srvcRegGroups) ) continue;
                    discardedMap.remove(srvcReg);
                    expectedNoInterestDiscardedMap.remove(srvcReg);
                    expectedPassiveDiscardedMap.remove(srvcReg);
                    expectedDiscoveredMap.put(srvcReg,srvcRegGroups);
                }//end loop
            }//end sync(this)
            /* If one of the groups or locs to discover corresponds to one
             * or more of the lookups that were started but have not yet
             * been discovered (that is, the group or loc to discover does not
             * correspond to any element of the discoveredMap), then add
             * those un-discovered lookups to the expectedDiscoveredMap.
             */
            synchronized(lockObject) {
                Iterator iter = genMap.keySet().iterator();
                while(iter.hasNext()) {
                    Object curGen = iter.next();
                    ServiceRegistrar srvcReg = null;
                    LookupLocator srvcRegLoc = null;
                    /* retrieve the locator and member groups of cur lookup */
                    if( curGen instanceof DiscoveryProtocolSimulator ) {
                        DiscoveryProtocolSimulator generator
                                         = (DiscoveryProtocolSimulator)curGen;
                        srvcReg = generator.getLookupProxy();
                        srvcRegLoc = generator.getLookupLocator();
                    } else {
                        srvcReg = (ServiceRegistrar)curGen;
                        try {
                            srvcRegLoc = QAConfig.getConstrainedLocator(srvcReg.getLocator());
                        } catch(RemoteException e) {
                            e.printStackTrace();
                            continue;
                        }
                    }//endif
View Full Code Here


        private void initState() {
            synchronized(lockObject) {
                Iterator iter = genMap.keySet().iterator();
                for(int i=0;iter.hasNext();i++) {
                    Object curGen = iter.next();
                    ServiceRegistrar lookupProxy = null;
                    LookupLocator genLoc = null;
                    if( curGen instanceof DiscoveryProtocolSimulator ) {
                        DiscoveryProtocolSimulator generator
                                         = (DiscoveryProtocolSimulator)curGen;
                        lookupProxy = generator.getLookupProxy();
                        genLoc = generator.getLookupLocator();
                    } else {
                        lookupProxy = (ServiceRegistrar)curGen;
                        try {
                            genLoc = QAConfig.getConstrainedLocator(lookupProxy.getLocator());
                        } catch(RemoteException e) {
                            e.printStackTrace();
                        }
                    }//endif
                    String[] genGroups = (String[])genMap.get(curGen);
View Full Code Here

                                               (oldDesiredRegs,regInfo)// f.
                HashMap discardRegs = new HashMap(undesiredRegs.size());
                for(Iterator itr = (undesiredRegs.keySet()).iterator();
                                                              itr.hasNext(); )
                {
                    ServiceRegistrar reg = (ServiceRegistrar)itr.next();
                    (regInfo.discoveredRegsMap).remove(reg);              // g.
                    discardRegs.put(reg,
                    ((LocatorGroupsStruct)allDiscoveredRegs.get(reg)).groups);

                }//end loop
View Full Code Here

                 */
                HashMap discardRegs = new HashMap(undesiredRegs.size());
                for(Iterator itr = (undesiredRegs.keySet()).iterator();
                                                              itr.hasNext(); )
                {
                    ServiceRegistrar reg = (ServiceRegistrar)itr.next();
                    (regInfo.discoveredRegsMap).remove(reg);
                    discardRegs.put(reg,
                    ((LocatorGroupsStruct)allDiscoveredRegs.get(reg)).groups);
                }//end loop
                /* Construct the registrars-to-groups map for the event */
 
View Full Code Here

        try {
            final String serviceClassNames[] = substitute(serviceClasses);
            this.dbgSpecSrvcs(serviceClasses, serviceClassNames);

            if (useLookup) {
                ServiceRegistrar lookupProxy =
        manager.startLookupService(); // prepared by util
    // prepared by DiscoveryAdminUtil
                admin = DiscoveryAdminUtil.getDiscoveryAdmin(lookupProxy);
            }
View Full Code Here

                                  : (lusList.size() - (i%(lusList.size())) ) );
            ArrayList regInfoList = new ArrayList(nLookups);
            for(int j=0;j<nLookups;j++) {
                RegInfo regInfo = new RegInfo();
                int jndx = (lusList.size()-1) - j;
                ServiceRegistrar lookupProxy =
                                        (ServiceRegistrar)lusList.get(jndx);
                LookupLocator loc = null;
                try {
                    loc = QAConfig.getConstrainedLocator(lookupProxy.getLocator());
                } catch(Exception e) {
                    e.printStackTrace();
                    throw new RuntimeException(e.toString());
                }
                logger.log(Level.FINE, "registering test service "
                                              +i+" with lookup service "+loc);
                ServiceRegistration srvcReg =
                 lookupProxy.register(new ServiceItem(srvcID,testService,null),
                                      Long.MAX_VALUE);
    Lease srvcLease = null;
    try {
        srvcReg = (ServiceRegistration) getConfig().prepare(
           "test.reggieServiceRegistrationPreparer",
View Full Code Here

        long T0 = System.currentTimeMillis();
        long deltaT = 0;
        long maxT   = nSecsJoin * 1000; //work in milliseconds
        while(deltaT < maxT) {
            for(int i=0;i<lusList.size();i++) {
                ServiceRegistrar reg = (ServiceRegistrar)lusList.get(i);
                if(regList.contains(reg)) continue;
                try {
                    Object testService = reg.lookup(template);
                    if(testService instanceof TestService) {
                        regList.add(reg);
                    }//endif
                } catch(RemoteException e) { /* try again*/ }
            }//end loop
View Full Code Here

        /* Retrieve and store the service's ID as stored in each lookup */
        ArrayList lusList = getLookupListSnapshot
                                              ("AbstractBaseTest.verifyJoin");
        ArrayList srvcIDs = new ArrayList(lusList.size());
        for(int i=0;i<lusList.size();i++) {
            ServiceRegistrar reg = (ServiceRegistrar)lusList.get(i);
      /* Verify 1 service registered with lookup service i */
      ServiceMatches matches = reg.lookup(template,
            Integer.MAX_VALUE);
      if(matches.totalMatches == 0) {
    throw new TestException("lookup service "+i
                                        +" -- no matching service found");
      } else if(matches.totalMatches != 1) {
View Full Code Here

            long maxT   = nSecsWait * 1000; //work in milliseconds
            while(deltaT <= maxT) {
                int nRegs = regList.size();
                for(int i=0;i<nRegs;i++) {
                    /* Pop the stack of lookups */
                    ServiceRegistrar reg = (ServiceRegistrar)regList.remove(0);
        /* Verify 1 service registered with lookup service i */
        ServiceMatches matches = reg.lookup(template,
              Integer.MAX_VALUE);
        if(matches.totalMatches == 0) {
      throw new TestException("lookup service "+i
               +" -- no matching service found");
        } else if(matches.totalMatches != 1) {
      throw new TestException("lookup service "+i
            +" -- totalMatches ("
            +matches.totalMatches
            +") != 1");
        }//endif
        /* Verify that the given attributes were propagated */
        Entry[] lookupAttrs = matches.items[0].attributeSets;
        logger.log(Level.FINE, "lookup service "+i
             +" -- comparing attributes");
        if(!AttributesUtil.compareAttributeSets(attrs,
                  lookupAttrs,
                  Level.OFF))
                        {
                            logger.log(Level.FINE,
               "                 -- NO MATCH");
                            regList.add(reg);// push it back on the stack
                        } else {
                            logger.log(Level.FINE,
               "                 -- attributes MATCH");
                        }//endif
                 }//end loop
                if(regList.size() == 0) break;
                DiscoveryServiceUtil.delayMS(1000);
                deltaT = System.currentTimeMillis() - T0;
            }//end loop
            /* If propagation failed, display expected & actual attributes */
            if(regList.size() > 0) {
                String retStr = "attributes not propagated successfully "
                                   +"on "+regList.size()+" lookup service(s)";
                logger.log(Level.FINE, retStr);
                AttributesUtil.displayAttributeSet(attrs,
                                                   "expectedAttrs",
                                                   Level.FINE);
                for(int i=0;i<regList.size();i++) {
                    ServiceRegistrar reg = (ServiceRegistrar)regList.get(i);
        ServiceMatches matches = reg.lookup(template,
              Integer.MAX_VALUE);
        if(matches.totalMatches != 1) {
      logger.log(Level.FINE,
           "lookup service "+i+" -- totalMatches "
           +"invalid ("+matches.totalMatches+") ... "
View Full Code Here

         */
        HashMap regsToAdd = new HashMap(regsMap.size());
        Set eSet = regsMap.entrySet();
        for(Iterator itr = eSet.iterator(); itr.hasNext(); ) {
            Map.Entry pair = (Map.Entry)itr.next();
            ServiceRegistrar reg = (ServiceRegistrar)pair.getKey();
            LocatorGroupsStruct curStructVal
                                      = (LocatorGroupsStruct)pair.getValue();
            /* If regInfo wants ALL_GROUPS, then every registrar is desired */
            if(regInfo.groups == null) { // ALL_GROUPS
                regsToAdd.put(reg,curStructVal);
View Full Code Here

TOP

Related Classes of net.jini.core.lookup.ServiceRegistrar

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.