List of usage examples for com.google.common.util.concurrent ListenableFuture get
V get() throws InterruptedException, ExecutionException;
From source file:org.midonet.southbound.vtep.mock.MockOvsdbClient.java
@Override public <E extends TableSchema<E>> TableUpdates monitor(DatabaseSchema dbSchema, List<MonitorRequest<E>> requests, MonitorCallBack cb) { List<Operation> ops = new ArrayList<>(); for (MonitorRequest<E> e : requests) { monitorRegistrar.register(e.getTableName(), e.getColumns(), cb); Select<GenericTableSchema> query = new Select<>( vtepSchema.table(e.getTableName(), GenericTableSchema.class)); if (e.getColumns() != null) query.setColumns(Lists.newArrayList(e.getColumns())); ops.add(query);// w ww .j a va2 s. c o m } ListenableFuture<List<OperationResult>> results = transact(vtepSchema, ops); try { return tableUpdates(results.get()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return null; } catch (ExecutionException e) { log.error("exception on monitored table data", e); return null; } }
From source file:org.opendaylight.ovsdb.lib.it.LibraryIntegrationTestBase.java
public boolean isSchemaSupported(OvsdbClient client, String schema) throws ExecutionException, InterruptedException { ListenableFuture<List<String>> databases = client.getDatabases(); List<String> dbNames = databases.get(); assertNotNull(dbNames);/*w w w.ja v a 2 s .com*/ return dbNames.contains(schema); }
From source file:org.opendaylight.protocol.bgp.openconfig.impl.moduleconfig.BGPAppPeerProvider.java
public void onNeighborModified(final Neighbor modifiedAppNeighbor) { final ModuleKey moduleKey = neighborState.getModuleKey(modifiedAppNeighbor.getKey()); final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); if (moduleKey != null) { //update an existing peer configuration try {//from w w w .ja v a 2 s .com if (neighborState.addOrUpdate(moduleKey, modifiedAppNeighbor.getKey(), modifiedAppNeighbor)) { final Optional<Module> maybeModule = configModuleOp.readModuleConfiguration(moduleKey, rTx) .get(); if (maybeModule.isPresent()) { final Module peerConfigModule = toPeerConfigModule(modifiedAppNeighbor, maybeModule.get()); configModuleOp.putModuleConfiguration(peerConfigModule, dataBroker.newWriteOnlyTransaction()); } } } catch (final Exception e) { LOG.error("Failed to update a configuration module: {}", moduleKey, e); throw new IllegalStateException(e); } } else { //create new application peer configuration final ModuleKey ribImplKey = globalState.getModuleKey(GlobalIdentifier.GLOBAL_IDENTIFIER); if (ribImplKey != null) { try { final ListenableFuture<TargetRib> ribFuture = new RibInstanceFunction<>(rTx, configModuleOp, TO_RIB_FUNCTION).apply(ribImplKey.getName()); final Module peerConfigModule = toPeerConfigModule(modifiedAppNeighbor, ribFuture.get()); configModuleOp.putModuleConfiguration(peerConfigModule, dataBroker.newWriteOnlyTransaction()); neighborState.addOrUpdate(peerConfigModule.getKey(), modifiedAppNeighbor.getKey(), modifiedAppNeighbor); } catch (final Exception e) { LOG.error("Failed to create a configuration module: {}", moduleKey, e); throw new IllegalStateException(e); } } } }
From source file:org.opendaylight.controller.sal.restconf.impl.BrokerFacade.java
private void checkItemDoesNotExists(final DOMDataReadWriteTransaction rWTransaction, final LogicalDatastoreType store, final YangInstanceIdentifier path) { final ListenableFuture<Boolean> futureDatastoreData = rWTransaction.exists(store, path); try {//w ww . j av a 2 s . c o m if (futureDatastoreData.get()) { final String errMsg = "Post Configuration via Restconf was not executed because data already exists"; LOG.trace(errMsg + ":{}", path); rWTransaction.cancel(); throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS); } } catch (InterruptedException | ExecutionException e) { LOG.warn("It wasn't possible to get data loaded from datastore at path " + path, e); } }
From source file:com.facebook.buck.rules.CassandraArtifactCache.java
@Override @SuppressWarnings("PMD.EmptyCatchBlock") public void close() { isWaitingToClose.set(true);//from www . j a va2s . c om ListenableFuture<List<OperationResult<Void>>> future = Futures.allAsList(futures); try { future.get(); } catch (InterruptedException | ExecutionException e) { // Swallow exception and move on. } }
From source file:com.netflix.genie.agent.execution.services.impl.grpc.GRpcAgentJobServiceImpl.java
private <ResponseType> ResponseType handleResponseFuture( final ListenableFuture<ResponseType> responseListenableFuture) { final ResponseType response; try {/*from w ww .ja va2s. c o m*/ response = responseListenableFuture.get(); } catch (final ExecutionException | InterruptedException e) { throw new GenieRuntimeException("Failed to perform request", e); } return response; }
From source file:com.facebook.presto.chicago.ChicagoRecordCursor.java
private boolean fetchData(String keyString) { valueString = null;//from w w w . j a v a 2s . c o m log.info("--------------"); log.info(keyString); log.info("--------------"); log.info(split.getKeyDataFormat()); log.info("--------------"); log.info(split.getValueDataFormat()); try { switch (split.getValueDataType()) { case STRING: ListenableFuture<byte[]> resp = cc.read(split.getTableName().getBytes(), keyString.getBytes()); valueString = Arrays.asList(new String(resp.get()).split("@@@")).toString(); if (valueString == null) { log.warn("Chicago data modified while query was running, string value at key %s deleted", keyString); return false; } break; default: log.debug("Chicago type for key %s is unsupported", keyString); return false; } } catch (Exception e) { throw Throwables.propagate(e); } return true; }
From source file:org.thingsboard.server.controller.AssetController.java
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") @RequestMapping(value = "/asset/types", method = RequestMethod.GET) @ResponseBody/*from w w w .j ava 2 s .co m*/ public List<EntitySubtype> getAssetTypes() throws ThingsboardException { try { SecurityUser user = getCurrentUser(); TenantId tenantId = user.getTenantId(); ListenableFuture<List<EntitySubtype>> assetTypes = assetService.findAssetTypesByTenantId(tenantId); return checkNotNull(assetTypes.get()); } catch (Exception e) { throw handleException(e); } }
From source file:org.thingsboard.server.controller.EntityViewController.java
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") @RequestMapping(value = "/entityView", method = RequestMethod.POST) @ResponseBody/* ww w . ja v a2s .co m*/ public EntityView saveEntityView(@RequestBody EntityView entityView) throws ThingsboardException { try { entityView.setTenantId(getCurrentUser().getTenantId()); EntityView savedEntityView = checkNotNull(entityViewService.saveEntityView(entityView)); List<ListenableFuture<List<Void>>> futures = new ArrayList<>(); if (savedEntityView.getKeys() != null && savedEntityView.getKeys().getAttributes() != null) { futures.add(copyAttributesFromEntityToEntityView(savedEntityView, DataConstants.CLIENT_SCOPE, savedEntityView.getKeys().getAttributes().getCs(), getCurrentUser())); futures.add(copyAttributesFromEntityToEntityView(savedEntityView, DataConstants.SERVER_SCOPE, savedEntityView.getKeys().getAttributes().getSs(), getCurrentUser())); futures.add(copyAttributesFromEntityToEntityView(savedEntityView, DataConstants.SHARED_SCOPE, savedEntityView.getKeys().getAttributes().getSh(), getCurrentUser())); } for (ListenableFuture<List<Void>> future : futures) { try { future.get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException("Failed to copy attributes to entity view", e); } } logEntityAction(savedEntityView.getId(), savedEntityView, null, entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); return savedEntityView; } catch (Exception e) { logEntityAction(emptyId(EntityType.ENTITY_VIEW), entityView, null, entityView.getId() == null ? ActionType.ADDED : ActionType.UPDATED, e); throw handleException(e); } }
From source file:utils.teamcity.wallt.controller.api.ApiMonitoringService.java
private void checkBuildStatus(final Iterable<BuildTypeData> monitoredBuilds) { try {/*from w w w .j a v a 2s. co m*/ ListenableFuture<Void> future = Futures.immediateFuture(null); for (final BuildTypeData buildType : monitoredBuilds) future = Futures.transform(future, (AsyncFunction<Void, Void>) o -> _apiController.requestLastBuildStatus(buildType)); future.get(); } catch (InterruptedException | ExecutionException ignored) { } }