List of usage examples for java.util Collections emptySet
@SuppressWarnings("unchecked") public static final <T> Set<T> emptySet()
From source file:org.apache.solr.client.solrj.impl.CloudSolrClientCacheTest.java
public void testCaching() throws Exception { String collName = "gettingstarted"; Set<String> livenodes = new HashSet<>(); Map<String, ClusterState.CollectionRef> refs = new HashMap<>(); Map<String, DocCollection> colls = new HashMap<>(); class Ref extends ClusterState.CollectionRef { private String c; public Ref(String c) { super(null); this.c = c; }//from ww w. j av a2 s .co m @Override public boolean isLazilyLoaded() { return true; } @Override public DocCollection get() { gets.incrementAndGet(); return colls.get(c); } } Map<String, Function> responses = new HashMap<>(); NamedList okResponse = new NamedList(); okResponse.add("responseHeader", new NamedList<>(Collections.singletonMap("status", 0))); LBHttpSolrClient mockLbclient = getMockLbHttpSolrClient(responses); AtomicInteger lbhttpRequestCount = new AtomicInteger(); try (CloudSolrClient cloudClient = new CloudSolrClientBuilder(getStateProvider(livenodes, refs)) .withLBHttpSolrClient(mockLbclient).build()) { livenodes.addAll(ImmutableSet.of("192.168.1.108:7574_solr", "192.168.1.108:8983_solr")); ClusterState cs = ClusterState.load(1, coll1State.getBytes(UTF_8), Collections.emptySet(), "/collections/gettingstarted/state.json"); refs.put(collName, new Ref(collName)); colls.put(collName, cs.getCollectionOrNull(collName)); responses.put("request", o -> { int i = lbhttpRequestCount.incrementAndGet(); if (i == 1) return new ConnectException("TEST"); if (i == 2) return new SocketException("TEST"); if (i == 3) return new NoHttpResponseException("TEST"); return okResponse; }); UpdateRequest update = new UpdateRequest().add("id", "123", "desc", "Something 0"); cloudClient.request(update, collName); assertEquals(2, refs.get(collName).getCount()); } }
From source file:com.jgoetsch.ib.handlers.SingleHandlerManager.java
public Collection<EWrapper> getHandlers(String eventName, int objectId) { EWrapper handler, noObjectHandler;/*from w w w .j a va 2 s.co m*/ synchronized (this) { handler = handlerMap.get(eventName, objectId); noObjectHandler = handlerMap.get(eventName, 0); } if (handler != null && noObjectHandler != null && handler != noObjectHandler) return Arrays.asList(handler, noObjectHandler); else if (handler != null) return Collections.singleton(handler); else if (noObjectHandler != null) return Collections.singleton(noObjectHandler); else return Collections.emptySet(); }
From source file:org.yamj.core.database.service.CommonStorageService.java
/** * Delete a stage file and all associated entities. * * @param id/*from w w w. j a v a 2s . c o m*/ * @return list of cached file names which must be deleted also */ @Transactional public Set<String> deleteStageFile(Long id) { // get the stage file StageFile stageFile = this.stagingDao.getStageFile(id); // check stage file if (stageFile == null) { // not found return Collections.emptySet(); } if (StatusType.DELETED != stageFile.getStatus()) { // status must still be DELETE return Collections.emptySet(); } Set<String> filesToDelete; switch (stageFile.getFileType()) { case VIDEO: filesToDelete = this.deleteVideoStageFile(stageFile); break; case IMAGE: filesToDelete = this.deleteImageStageFile(stageFile); break; case WATCHED: this.deleteWatchedStageFile(stageFile); filesToDelete = Collections.emptySet(); break; default: this.delete(stageFile); filesToDelete = Collections.emptySet(); break; } return filesToDelete; }
From source file:gov.nih.nci.caintegrator.application.query.CopyNumberAlterationCriterionHandler.java
/** * {@inheritDoc}//from www . j a va2 s. c o m */ @Override Set<AbstractReporter> getReporterMatches(CaIntegrator2Dao dao, Study study, ReporterTypeEnum reporterType, Platform platform) { return Collections.emptySet(); }
From source file:com.edmunds.etm.system.impl.ControllerMonitor.java
@Autowired public ControllerMonitor(ZooKeeperConnection connection, ControllerPaths controllerPaths, ObjectSerializer objectSerializer, ProjectProperties projectProperties, FailoverMonitor failoverMonitor) { this.connection = connection; this.controllerPaths = controllerPaths; this.objectSerializer = objectSerializer; this.failoverMonitor = failoverMonitor; this.localController = createControllerInstance(projectProperties); this.callbackInstance = new Callback(); this.peerControllers = Collections.emptySet(); // Register for failover notifications failoverMonitor.addListener(this); // Initialize zookeeper tree watcher this.controllerWatcher = new ZooKeeperTreeWatcher(connection, 0, controllerPaths.getConnected(), callbackInstance);//from w ww .j a va2 s.c om }
From source file:org.eclipse.winery.repository.resources.imports.xsdimports.XSDImportResource.java
@SuppressWarnings("unchecked") public Collection<String> getAllDefinedLocalNames(short type) { RepositoryFileReference ref = this.getXSDFileReference(); if (ref == null) { return Collections.emptySet(); }/*from ww w. j av a 2 s . c o m*/ Date lastUpdate = Repository.INSTANCE.getLastUpdate(ref); String cacheFileName = "definedLocalNames " + Integer.toString(type) + ".cache"; RepositoryFileReference cacheRef = new RepositoryFileReference(this.id, cacheFileName); boolean cacheNeedsUpdate = true; if (Repository.INSTANCE.exists(cacheRef)) { Date lastUpdateCache = Repository.INSTANCE.getLastUpdate(cacheRef); if (lastUpdate.compareTo(lastUpdateCache) <= 0) { cacheNeedsUpdate = false; } } List<String> result; if (cacheNeedsUpdate) { XSModel model = this.getXSModel(); if (model == null) { return Collections.emptySet(); } XSNamedMap components = model.getComponents(type); //@SuppressWarnings("unchecked") int len = components.getLength(); result = new ArrayList<>(len); for (int i = 0; i < len; i++) { XSObject item = components.item(i); // if queried for TYPE_DEFINITION, then XSD base types (such as IDREF) are also returned // We want to return only types defined in the namespace of this resource if (item.getNamespace().equals(this.id.getNamespace().getDecoded())) { result.add(item.getName()); } } String cacheContent = null; try { cacheContent = Utils.mapper.writeValueAsString(result); } catch (JsonProcessingException e) { XSDImportResource.LOGGER.error("Could not generate cache content", e); } try { Repository.INSTANCE.putContentToFile(cacheRef, cacheContent, MediaType.APPLICATION_JSON_TYPE); } catch (IOException e) { XSDImportResource.LOGGER.error("Could not update cache", e); } } else { // read content from cache // cache should contain most recent information try (InputStream is = Repository.INSTANCE.newInputStream(cacheRef)) { result = Utils.mapper.readValue(is, java.util.List.class); } catch (IOException e) { XSDImportResource.LOGGER.error("Could not read from cache", e); result = Collections.emptyList(); } } return result; }
From source file:io.github.moosbusch.lumpi.application.spi.AbstractLumpiApplication.java
@Override public Collection<String> getBeanConfigurationPackages() { return Collections.emptySet(); }
From source file:ca.uhn.fhir.jpa.dao.SearchParamExtractorDstu1.java
@Override public Set<ResourceIndexedSearchParamCoords> extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource) { return Collections.emptySet(); }
From source file:io.scigraph.internal.CypherUtil.java
public Set<RelationshipType> getEntailedRelationshipTypes(Collection<String> parents) { Set<String> relationshipNames = getEntailedRelationshipNames(parents); Collection<RelationshipType> relationshipTypes = Collections.emptySet(); try (Transaction tx = graphDb.beginTx()) { relationshipTypes = transform(relationshipNames, new Function<String, RelationshipType>() { @Override//from w ww .ja v a 2 s. co m public RelationshipType apply(String name) { return DynamicRelationshipType.withName(name); } }); tx.success(); } return new HashSet<RelationshipType>(relationshipTypes); }
From source file:io.mandrel.transport.thrift.ThriftClients.java
@PostConstruct public void init() { GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig(); poolConfig.setMaxTotalPerKey(4);//from w w w. j av a2s .c om poolConfig.setMinIdlePerKey(1); ThriftCatalog catalog = new ThriftCatalog(); catalog.addDefaultCoercions(MandrelCoercions.class); ThriftCodecManager codecManager = new ThriftCodecManager( new CompilerThriftCodecFactory(ThriftCodecManager.class.getClassLoader()), catalog, Collections.emptySet()); NettyClientConfig config = NettyClientConfig.newBuilder().build(); NiftyClient niftyClient = new NiftyClient(config, local); ThriftClientManager clientManager = new ThriftClientManager(codecManager, niftyClient, Collections.emptySet()); frontiers = new KeyedClientPool<>(FrontierContract.class, poolConfig, 9090, // Deflater.BEST_SPEED null, clientManager); prepare(frontiers); controllers = new KeyedClientPool<>(ControllerContract.class, poolConfig, 9090, // Deflater.BEST_SPEED null, clientManager); prepare(controllers); workers = new KeyedClientPool<>(WorkerContract.class, poolConfig, 9090, // Deflater.BEST_SPEED null, clientManager); prepare(workers); nodes = new KeyedClientPool<>(NodeContract.class, poolConfig, 9090, // Deflater.BEST_SPEED null, clientManager); prepare(nodes); }