Java Code Examples for java.util.Collections.EMPTY_SET

The following are Jave code examples for showing how to use EMPTY_SET of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: IssueSettingsStorage.java   View Source Code Vote up 6 votes
public Collection<Long> loadCollapsedCommenst(String repoUrl, String id) {
    File file = getIssuePropertiesFile(repoUrl, id);
    FileLocks.FileLock l = FileLocks.getLock(file);
    try {
        Properties p = load(file, repoUrl, id);
        Set<Long> s = new HashSet<Long>();
        for(Object k : p.keySet()) {
            String key = k.toString();
            if(key.startsWith(PROP_COLLAPSED_COMMENT_PREFIX) && "true".equals(p.get(key))) {
                s.add(Long.parseLong(key.substring(PROP_COLLAPSED_COMMENT_PREFIX.length())));
            }
        }
        return s;
    } catch (IOException ex) {
        Support.LOG.log(Level.WARNING, repoUrl + " " + id, ex);
    } finally {
        l.release();
    }
            
    return Collections.EMPTY_SET;
}
 
Example 2
Project: monarch   File: GemFireCacheImpl.java   View Source Code Vote up 6 votes
public Set<InetSocketAddress> getCurrentServers() {
  Map<String, Pool> pools = PoolManager.getAll();
  Set result = null;
  for (Pool p : pools.values()) {
    PoolImpl pi = (PoolImpl) p;
    for (Object o : pi.getCurrentServers()) {
      ServerLocation sl = (ServerLocation) o;
      if (result == null) {
        result = new HashSet<DistributedMember>();
      }
      result.add(new InetSocketAddress(sl.getHostName(), sl.getPort()));
    }
  }
  if (result == null) {
    return Collections.EMPTY_SET;
  } else {
    return result;
  }
}
 
Example 3
Project: monarch   File: StartupMessage.java   View Source Code Vote up 5 votes
/**
 * Determine all of the addresses that this host represents. An empty list will be regarded as an
 * error by all who see it.
 * 
 * @return list of addresses for this host
 * @since GemFire 5.7
 */
public static Set getMyAddresses(DistributionManager dm) {
  try {
    Set addresses = SocketCreator.getMyAddresses();
    return addresses;
  } catch (IllegalArgumentException e) {
    logger.fatal(e.getMessage(), e);
    return Collections.EMPTY_SET;
  }
}
 
Example 4
Project: openjdk-jdk10   File: ConnectionTest.java   View Source Code Vote up 5 votes
public Subject authenticate(Object credentials) {
    Subject subject =
        new Subject(true, bogusPrincipals,
                    Collections.EMPTY_SET, Collections.EMPTY_SET);
    System.out.println("Authenticator returns: " + subject);
    return subject;
}
 
Example 5
Project: ipack   File: X509StoreLDAPCRLs.java   View Source Code Vote up 5 votes
/**
 * Returns a collection of matching CRLs from the LDAP location.
 * <p/>
 * The selector must be a of type <code>X509CRLStoreSelector</code>. If
 * it is not an empty collection is returned.
 * <p/>
 * The issuer should be a reasonable criteria for a selector.
 *
 * @param selector The selector to use for finding.
 * @return A collection with the matches.
 * @throws StoreException if an exception occurs while searching.
 */
public Collection engineGetMatches(Selector selector) throws StoreException
{
    if (!(selector instanceof X509CRLStoreSelector))
    {
        return Collections.EMPTY_SET;
    }
    X509CRLStoreSelector xselector = (X509CRLStoreSelector)selector;
    Set set = new HashSet();
    // test only delta CRLs should be selected
    if (xselector.isDeltaCRLIndicatorEnabled())
    {
        set.addAll(helper.getDeltaCertificateRevocationLists(xselector));
    }
    // nothing specified
    else
    {
        set.addAll(helper.getDeltaCertificateRevocationLists(xselector));
        set.addAll(helper.getAttributeAuthorityRevocationLists(xselector));
        set
            .addAll(helper
                .getAttributeCertificateRevocationLists(xselector));
        set.addAll(helper.getAuthorityRevocationLists(xselector));
        set.addAll(helper.getCertificateRevocationLists(xselector));
    }
    return set;
}
 
Example 6
Project: openjdk-jdk10   File: NotificationEmissionTest.java   View Source Code Vote up 5 votes
public Subject authenticate(Object credentials) {
    String role = ((String[]) credentials)[0];
    echo("Create principal with name = " + role);
    return new Subject(true,
                       Collections.singleton(new JMXPrincipal(role)),
                       Collections.EMPTY_SET,
                       Collections.EMPTY_SET);
}
 
Example 7
Project: monarch   File: DistTXRollbackMessage.java   View Source Code Vote up 5 votes
public Set getCacheClosedMembers() {
  if (this.exception != null) {
    DistTxRollbackExceptionCollectingException cce =
        (DistTxRollbackExceptionCollectingException) this.exception;
    return cce.getCacheClosedMembers();
  } else {
    return Collections.EMPTY_SET;
  }
}
 
Example 8
Project: monarch   File: DistTXPrecommitMessage.java   View Source Code Vote up 5 votes
public Set getRegionDestroyedMembers(String regionFullPath) {
  if (this.exception != null) {
    DistTxPrecommitExceptionCollectingException cce =
        (DistTxPrecommitExceptionCollectingException) this.exception;
    return cce.getRegionDestroyedMembers(regionFullPath);
  } else {
    return Collections.EMPTY_SET;
  }
}
 
Example 9
Project: openjdk-jdk10   File: RMIConnectorInternalMapTest.java   View Source Code Vote up 4 votes
public static void main(String[] args) throws Exception {
    System.out.println("---RMIConnectorInternalMapTest starting...");

    JMXConnectorServer connectorServer = null;
    JMXConnector connectorClient = null;

    try {
        MBeanServer mserver = ManagementFactory.getPlatformMBeanServer();
        JMXServiceURL serverURL = new JMXServiceURL("rmi", "localhost", 0);
        connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serverURL, null, mserver);
        connectorServer.start();

        JMXServiceURL serverAddr = connectorServer.getAddress();
        connectorClient = JMXConnectorFactory.connect(serverAddr, null);
        connectorClient.connect();

        Field rmbscMapField = RMIConnector.class.getDeclaredField("rmbscMap");
        rmbscMapField.setAccessible(true);
        Map<Subject, WeakReference<MBeanServerConnection>> map =
                (Map<Subject, WeakReference<MBeanServerConnection>>) rmbscMapField.get(connectorClient);
        if (map != null && !map.isEmpty()) { // failed
            throw new RuntimeException("RMIConnector's rmbscMap must be empty at the initial time.");
        }

        Subject delegationSubject =
                new Subject(true,
                Collections.singleton(new JMXPrincipal("delegate")),
                Collections.EMPTY_SET,
                Collections.EMPTY_SET);
        MBeanServerConnection mbsc1 =
                connectorClient.getMBeanServerConnection(delegationSubject);
        MBeanServerConnection mbsc2 =
                connectorClient.getMBeanServerConnection(delegationSubject);

        if (mbsc1 == null) {
            throw new RuntimeException("Got null connection.");
        }
        if (mbsc1 != mbsc2) {
            throw new RuntimeException("Not got same connection with a same subject.");
        }

        map = (Map<Subject, WeakReference<MBeanServerConnection>>) rmbscMapField.get(connectorClient);
        if (map == null || map.isEmpty()) { // failed
            throw new RuntimeException("RMIConnector's rmbscMap has wrong size "
                    + "after creating a delegated connection.");
        }

        delegationSubject = null;
        mbsc1 = null;
        mbsc2 = null;

        int i = 0;
        while (!map.isEmpty() && i++ < 60) {
            System.gc();
            Thread.sleep(100);
        }
        System.out.println("---GC times: " + i);

        if (!map.isEmpty()) {
            throw new RuntimeException("Failed to clean RMIConnector's rmbscMap");
        } else {
            System.out.println("---RMIConnectorInternalMapTest: PASSED!");
        }
    } finally {
        try {
            connectorClient.close();
            connectorServer.stop();
        } catch (Exception e) {
        }
    }
}
 
Example 10
Project: Tarski   File: AbstractCollector.java   View Source Code Vote up 4 votes
/**
 * Returns Collections.EMPTY_SET
 * @return Collections.EMPTY_SET
 */
@SuppressWarnings("unchecked")
public Set<T> visit(ConstantFormula constant) {
	return Collections.EMPTY_SET;
}
 
Example 11
Project: incubator-netbeans   File: PlatformInstallIteratorTest.java   View Source Code Vote up 4 votes
public Set instantiate() throws IOException {
    return Collections.EMPTY_SET;
}
 
Example 12
Project: athena   File: McastRouteInfo.java   View Source Code Vote up 4 votes
public static McastRouteInfo mcastRouteInfo(McastRoute route,
                                            ConnectPoint sink,
                                            ConnectPoint source) {
    return new McastRouteInfo(route, sink, source, Collections.EMPTY_SET);
}
 
Example 13
Project: jdk8u-jdk   File: RMIConnectorInternalMapTest.java   View Source Code Vote up 4 votes
public static void main(String[] args) throws Exception {
    System.out.println("---RMIConnectorInternalMapTest starting...");

    JMXConnectorServer connectorServer = null;
    JMXConnector connectorClient = null;

    try {
        MBeanServer mserver = ManagementFactory.getPlatformMBeanServer();
        JMXServiceURL serverURL = new JMXServiceURL("rmi", "localhost", 0);
        connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serverURL, null, mserver);
        connectorServer.start();

        JMXServiceURL serverAddr = connectorServer.getAddress();
        connectorClient = JMXConnectorFactory.connect(serverAddr, null);
        connectorClient.connect();

        Field rmbscMapField = RMIConnector.class.getDeclaredField("rmbscMap");
        rmbscMapField.setAccessible(true);
        Map<Subject, WeakReference<MBeanServerConnection>> map =
                (Map<Subject, WeakReference<MBeanServerConnection>>) rmbscMapField.get(connectorClient);
        if (map != null && !map.isEmpty()) { // failed
            throw new RuntimeException("RMIConnector's rmbscMap must be empty at the initial time.");
        }

        Subject delegationSubject =
                new Subject(true,
                Collections.singleton(new JMXPrincipal("delegate")),
                Collections.EMPTY_SET,
                Collections.EMPTY_SET);
        MBeanServerConnection mbsc1 =
                connectorClient.getMBeanServerConnection(delegationSubject);
        MBeanServerConnection mbsc2 =
                connectorClient.getMBeanServerConnection(delegationSubject);

        if (mbsc1 == null) {
            throw new RuntimeException("Got null connection.");
        }
        if (mbsc1 != mbsc2) {
            throw new RuntimeException("Not got same connection with a same subject.");
        }

        map = (Map<Subject, WeakReference<MBeanServerConnection>>) rmbscMapField.get(connectorClient);
        if (map == null || map.isEmpty()) { // failed
            throw new RuntimeException("RMIConnector's rmbscMap has wrong size "
                    + "after creating a delegated connection.");
        }

        delegationSubject = null;
        mbsc1 = null;
        mbsc2 = null;

        int i = 0;
        while (!map.isEmpty() && i++ < 60) {
            System.gc();
            Thread.sleep(100);
        }
        System.out.println("---GC times: " + i);

        if (!map.isEmpty()) {
            throw new RuntimeException("Failed to clean RMIConnector's rmbscMap");
        } else {
            System.out.println("---RMIConnectorInternalMapTest: PASSED!");
        }
    } finally {
        try {
            connectorClient.close();
            connectorServer.stop();
        } catch (Exception e) {
        }
    }
}
 
Example 14
Project: monarch   File: PartitionedRegion.java   View Source Code Vote up 4 votes
/**
 * Test Method: Get a random set of keys from a randomly selected bucket using the provided
 * <code>Random</code> number generator.
 * 
 * @param rnd
 * @return A set of keys from a randomly chosen bucket or {@link Collections#EMPTY_SET}
 * @throws IOException
 * @throws ClassNotFoundException
 */
public Set getSomeKeys(Random rnd) throws IOException, ClassNotFoundException {
  InternalDistributedMember nod = null;
  Integer buck = null;
  Set buks = getRegionAdvisor().getBucketSet();

  if (buks != null && !buks.isEmpty()) {
    Object[] buksA = buks.toArray();
    Set ret = null;
    // Randomly pick a node to get some data from
    for (int i = 0; i < buksA.length; i++) {
      try {
        logger.debug("getSomeKeys: iteration: {}", i);
        int ind = rnd.nextInt(buksA.length);
        if (ind >= buksA.length) {
          // The GSRandom.nextInt(int) may return a value that includes the
          // maximum.
          ind = buksA.length - 1;
        }
        buck = (Integer) buksA[ind];

        nod = getNodeForBucketRead(buck.intValue());
        if (nod != null) {
          logger.debug("getSomeKeys: iteration: {} for node {}", i, nod);
          if (nod.equals(getMyId())) {
            ret =
                dataStore.handleRemoteGetKeys(buck, InterestType.REGULAR_EXPRESSION, ".*", false);
          } else {
            FetchKeysResponse r = FetchKeysMessage.send(nod, this, buck, false);
            ret = r.waitForKeys();
          }

          if (ret != null && !ret.isEmpty()) {
            return ret;
          }
        }
      } catch (ForceReattemptException movinOn) {
        checkReadiness();
        logger.debug(
            "Test hook getSomeKeys caught a ForceReattemptException for bucketId={}{}{}. Moving on to another bucket",
            getPRId(), BUCKET_ID_SEPARATOR, buck, movinOn);
        continue;
      } catch (PRLocallyDestroyedException pde) {
        logger.debug("getSomeKeys: Encountered PRLocallyDestroyedException");
        checkReadiness();
        continue;
      }

    } // nod != null
  } // for
  logger.debug("getSomeKeys: no keys found returning empty set");
  return Collections.EMPTY_SET;
}
 
Example 15
Project: incubator-netbeans   File: IncludeResolver.java   View Source Code Vote up 4 votes
/**
     * It looks for a set of schema models, which can be visible to each others.
     * The matter is, if model A includes B, then model B model's definitions
     * is visible to A. But the oposite assertion is also correct because B
     * logically becomes a part of A after inclusion.
     *
     * The method doesn't analyze models included to current. It looks only
     * models to which current model is included! It is implied that the included
     * models's hierarchy has checked before.
     *
     * Be carefull with the following use-case:
     * If model A includes B and C includes B then it doesn't mean that declarations
     * from model C visible in A.
     *
     * The problem is described in the issue http://www.netbeans.org/issues/show_bug.cgi?id=122836
     *
     * The task of the method is to find a set of schema models, which
     * can be visible to the current model. The parameter is used as a hint
     * to exclude the models from other namespace.
     *
     * @param soughtNs
     * @return
     */
    static Set<SchemaModelImpl> getMegaIncludedModels(
            SchemaModelImpl sModel, String soughtNs, ResolveSession session) {
        //
//        if (true) {
//            // For optimization tests only
              // Uncomment and run tests to check how often the mega-include is called. 
//            throw new RuntimeException("MEGA INCLUDE");
//        }
        //
        Schema mySchema = sModel.getSchema();
        if (mySchema == null) {
            return Collections.EMPTY_SET;
        }
        //
        // If the current model has empty target namespace, then it can be included anywhere
        // If the current model has not empty target namespace, then it can be included only
        // to models with the same target namespace.
        String myTargetNs = mySchema.getTargetNamespace();
        if (myTargetNs != null && !Util.equal(soughtNs, myTargetNs)) {
            return Collections.EMPTY_SET;
        }
        //
        // The graph is lazy initialized in session and can be reused during
        // the resolve session.
        BidirectionalGraph<SchemaModelImpl> graph = 
                session.getInclusionGraph(sModel, soughtNs);
        //
        // Now there is forward and back inclusion graphs.
        if (graph.isEmpty()) {
            return Collections.EMPTY_SET;
        }
        //
        // Look for the roots of inclusion.
        // Root s the top schema model, which includes current schema recursively,
        // but isn't included anywhere itself.
        Set<SchemaModelImpl> inclusionRoots = graph.getRoots(sModel, false);
        //
        HashSet<SchemaModelImpl> result = new HashSet<SchemaModelImpl>();
        for (SchemaModelImpl root : inclusionRoots) {
            // The namespace of the inclusion root has to be exectly the same
            // as required.
            if (Util.equal(root.getSchema().getTargetNamespace(), soughtNs)) {
                MultivalueMap.Utils.populateAllSubItems(graph, root, sModel, result);
            }
        }
        //
        result.remove(sModel);
        //
        return result;
    }
 
Example 16
Project: monarch   File: TXLockServiceDUnitTest.java   View Source Code Vote up 4 votes
@Test
public void testTXRecoverGrantorMessageProcessor() throws Exception {
  TXLockService.createDTLS();
  checkDLockRecoverGrantorMessageProcessor();

  /*
   * call TXRecoverGrantorMessageProcessor.process directly to make sure that correct behavior
   * occurs
   */

  // get txLock and hold it
  final Set participants = Collections.EMPTY_SET;
  final List regionLockReqs = new ArrayList();
  regionLockReqs.add(new TXRegionLockRequestImpl("/testTXRecoverGrantorMessageProcessor",
      new HashSet(Arrays.asList(new String[] {"KEY-1", "KEY-2", "KEY-3", "KEY-4"}))));
  TXLockService dtls = TXLockService.getDTLS();
  TXLockId txLockId = dtls.txLock(regionLockReqs, participants);

  // async call TXRecoverGrantorMessageProcessor.process
  final DLockService dlock = ((TXLockServiceImpl) dtls).getInternalDistributedLockService();
  final TestDLockRecoverGrantorProcessor testProc =
      new TestDLockRecoverGrantorProcessor(dlock.getDistributionManager(), Collections.EMPTY_SET);
  assertEquals("No valid processorId", true, testProc.getProcessorId() > -1);

  final DLockRecoverGrantorProcessor.DLockRecoverGrantorMessage msg =
      new DLockRecoverGrantorProcessor.DLockRecoverGrantorMessage();
  msg.setServiceName(dlock.getName());
  msg.setProcessorId(testProc.getProcessorId());
  msg.setSender(dlock.getDistributionManager().getId());

  Thread thread = new Thread(() -> {
    TXRecoverGrantorMessageProcessor proc =
        (TXRecoverGrantorMessageProcessor) dlock.getDLockRecoverGrantorMessageProcessor();
    proc.processDLockRecoverGrantorMessage(dlock.getDistributionManager(), msg);
  });
  thread.setName("TXLockServiceDUnitTest thread");
  thread.setDaemon(true);
  thread.start();

  await("waiting for recovery message to block").atMost(999, TimeUnit.MILLISECONDS).until(() -> {
    return ((TXLockServiceImpl) dtls).isRecovering();
  });

  dtls.release(txLockId);

  // check results to verify no locks were provided in the reply
  await("waiting for thread to exit").atMost(30, TimeUnit.SECONDS).until(() -> {
    return !thread.isAlive();
  });

  assertFalse(((TXLockServiceImpl) dtls).isRecovering());

  assertEquals("testTXRecoverGrantor_replyCode_PASS is false", true,
      testTXRecoverGrantor_replyCode_PASS);
  assertEquals("testTXRecoverGrantor_heldLocks_PASS is false", true,
      testTXRecoverGrantor_heldLocks_PASS);
}
 
Example 17
Project: monarch   File: CacheCreation.java   View Source Code Vote up 4 votes
public Set<DistributedMember> getMembers() {
  return Collections.EMPTY_SET;
}
 
Example 18
Project: Elasticsearch   File: PercolateContext.java   View Source Code Vote up 4 votes
@Override
public Set<String> getHeaders() {
    return Collections.EMPTY_SET;
}
 
Example 19
Project: ipack   File: X509StoreLDAPAttrCerts.java   View Source Code Vote up 3 votes
/**
 * Returns a collection of matching attribute certificates from the LDAP
 * location.
 * <p/>
 * The selector must be a of type
 * <code>X509AttributeCertStoreSelector</code>. If it is not an empty
 * collection is returned.
 * <p/>
 * <p/>
 * The subject and the serial number should be reasonable criterias for a
 * selector.
 *
 * @param selector The selector to use for finding.
 * @return A collection with the matches.
 * @throws StoreException if an exception occurs while searching.
 */
public Collection engineGetMatches(Selector selector) throws StoreException
{
    if (!(selector instanceof X509AttributeCertStoreSelector))
    {
        return Collections.EMPTY_SET;
    }
    X509AttributeCertStoreSelector xselector = (X509AttributeCertStoreSelector)selector;
    Set set = new HashSet();
    set.addAll(helper.getAACertificates(xselector));
    set.addAll(helper.getAttributeCertificateAttributes(xselector));
    set.addAll(helper.getAttributeDescriptorCertificates(xselector));
    return set;
}
 
Example 20
Project: jdk8u-jdk   File: CollectionCertStoreParameters.java   View Source Code Vote up 2 votes
/**
 * Creates an instance of {@code CollectionCertStoreParameters} with
 * the default parameter values (an empty and immutable
 * {@code Collection}).
 */
public CollectionCertStoreParameters() {
    coll = Collections.EMPTY_SET;
}