當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncResult類代碼示例

本文整理匯總了Java中org.springframework.scheduling.annotation.AsyncResult的典型用法代碼示例。如果您正苦於以下問題:Java AsyncResult類的具體用法?Java AsyncResult怎麽用?Java AsyncResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AsyncResult類屬於org.springframework.scheduling.annotation包,在下文中一共展示了AsyncResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scheduleItems

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Async
@Override
public Future<List<GetPrizeDTO>> scheduleItems(ScheduleItem item) throws InterruptedException {
    log.info("Start Schedule with : " +item.getRecipientID());
    log.info("query Type " + item.getQueryType());
    Future<List<GetPrizeDTO>> result = new AsyncResult<>(new ArrayList<>());
    if(item.getQueryType() == ConstantUtil.NORMAL_QUERY) {
        result = new AsyncResult<>(resultService.findPrizeByResultType(item.getLotteryType(), item.getParam().toArray(new String[]{})));
    } else if(item.getQueryType() == ConstantUtil.CODE_RANGE_QUERY) {
        result = new AsyncResult<>(resultService.findPrizesByCode(item.getParam().get(0), item.getParam().get(1), item.getParam().get(2), item.getLotteryType()));
    } else if(item.getQueryType() == ConstantUtil.POINT_RANGE_QUERY) {
        result = new AsyncResult<>(resultService.findPrizesByPoints(item.getParam().get(0), item.getParam().get(1), item.getParam().get(2), item.getLotteryType()));
    }
    // remove from db after finding result.
    deleteScheduleItem(item.getRecipientID());
    return result;
}
 
開發者ID:kyawswa,項目名稱:myanmarlottery,代碼行數:18,代碼來源:ScheduleServiceImpl.java

示例2: userStatusReq

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
/**
 * 查詢用戶在線狀態
 * 
 * @param fromUserId 用戶ID
 * @param userIdList 查詢列表
 * @return
 * @since  1.0
 */
@Async
public ListenableFuture<List<IMBaseDefine.UserStat>> userStatusReq(Long fromUserId, List<Long> userIdList) {
    
    logger.debug("查詢用戶在線狀態, user_cnt={}", userIdList.size());
    
    List<IMBaseDefine.UserStat> userStatList = new ArrayList<>();
    for (Long userId: userIdList) {
        
        UserClientInfoManager.UserClientInfo userClientInfo = userClientInfoManager.getUserInfo(userId);
        IMBaseDefine.UserStat.Builder userStatBuiler = IMBaseDefine.UserStat.newBuilder();
        userStatBuiler.setUserId(userId);
        if (userClientInfo != null) {
            userStatBuiler.setStatus(userClientInfo.getStatus());
        } else {
            userStatBuiler.setStatus(IMBaseDefine.UserStatType.USER_STATUS_OFFLINE);
        }
        
        userStatList.add(userStatBuiler.build());
    }
    
    AsyncResult<List<IMBaseDefine.UserStat>> result = new AsyncResult<>(userStatList);
    return result;
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:32,代碼來源:MessageServerCluster.java

示例3: getRxJavaDTO

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
/**
 * 異步執行,需要返回的Future<>類型
 *
 * @param name
 * @return
 */
@Async
public Future<RxJavaDTO> getRxJavaDTO(String name) {
    try {
        Thread.sleep(100);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    log.info("common service begin to process");
    RxJavaDTO item = new RxJavaDTO();
    item.setName(name);
    String value = MDC.get(MdcConstans.MDC_REMOTE_IP);
    if (!StringUtils.isEmpty(value)) {
        log.info("remoteid id " + value);
    } else {
        log.info("remoteid id is empty");
    }
    value = MDC.get(MdcConstans.MDC_ClientRequest_ID);
    if (!StringUtils.isEmpty(value)) {
        log.info("client id " + value);
    } else {
        log.info("client id is empty");
    }
    log.info("common service end to process");
    return new AsyncResult<>(item);
}
 
開發者ID:bobxwang,項目名稱:springboot-scala-withswagger,代碼行數:32,代碼來源:CommonService.java

示例4: execute

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
public Future<List<Event>> execute(Event event, Device device) {

    List<Event> outEvents = new ArrayList<>();

    ServiceResponse<List<EventRoute>> serviceRoutes = eventRouteService.getAll(device.getTenant(), device.getApplication());
    if (!serviceRoutes.isOk()) {
        LOGGER.error("Error listing application events routes", device.toURI(), device.getTenant().getLogLevel());
        return new AsyncResult<>(outEvents);
    }

    List<EventRoute> eventRoutes = serviceRoutes.getResult();
    if (eventRoutes.isEmpty()) {
        return new AsyncResult<>(outEvents);
    }

    eventRoutes.parallelStream().forEach((eventRoute) ->
        processEventRoute(event, device, outEvents, eventRoute)
    );

    return new AsyncResult<>(outEvents);
}
 
開發者ID:KonkerLabs,項目名稱:konker-platform,代碼行數:23,代碼來源:EventRouteExecutorImpl.java

示例5: runTask

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Async
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Future<Boolean> runTask(Integer jobId) throws AsyncTaskException {
    Job job = this.jobRepo.findOne(jobId);
    try {
        this.restorer.restore(job.getDbDumperServiceInstance(), job.getDatabaseRefTarget(), job.getDumpDate());
    } catch (RestoreException e) {
        logger.error(String.format("Cannot restore dump for '%s' in '%s': %s", job.getDatabaseRefSrc().getDatabaseName(), job.getDatabaseRefTarget().getDatabaseName(), e.getMessage()));
        job.setJobEvent(JobEvent.ERRORED);
        job.setErrorMessage(e.getMessage());
        this.databaseRefManager.deleteServiceKey(job);
        jobRepo.save(job);
        return new AsyncResult<Boolean>(false);
    }
    this.databaseRefManager.deleteServiceKey(job);
    job.setJobEvent(JobEvent.FINISHED);
    jobRepo.save(job);
    return new AsyncResult<Boolean>(true);
}
 
開發者ID:orange-cloudfoundry,項目名稱:db-dumper-service,代碼行數:20,代碼來源:RestoreDumpTask.java

示例6: processBusinessObjectDataNotificationEventAsync

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
@Async
public Future<Void> processBusinessObjectDataNotificationEventAsync(NotificationEventTypeEntity.EventTypesBdata notificationEventType,
    BusinessObjectDataKey businessObjectDataKey, String newBusinessObjectDataStatus, String oldBusinessObjectDataStatus)
{
    /*
     * Need to clear the security context here since the current thread may have been reused, which may might have left over its security context. If we do
     * not clear the security context, any subsequent calls may be restricted by the permissions given to the previous thread's security context.
     */
    SecurityContextHolder.clearContext();

    processBusinessObjectDataNotificationEventSync(notificationEventType, businessObjectDataKey, newBusinessObjectDataStatus, oldBusinessObjectDataStatus);

    // Return an AsyncResult so callers will know the future is "done". They can call "isDone" to know when this method has completed and they
    // can call "get" to see if any exceptions were thrown.
    return new AsyncResult<>(null);
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:18,代碼來源:NotificationEventServiceImpl.java

示例7: processStorageUnitNotificationEventAsync

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
@Async
public Future<Void> processStorageUnitNotificationEventAsync(NotificationEventTypeEntity.EventTypesStorageUnit notificationEventType,
    BusinessObjectDataKey businessObjectDataKey, String storageName, String newStorageUnitStatus, String oldStorageUnitStatus)
{
    /*
     * Need to clear the security context here since the current thread may have been reused, which may might have left over its security context. If we do
     * not clear the security context, any subsequent calls may be restricted by the permissions given to the previous thread's security context.
     */
    SecurityContextHolder.clearContext();

    processStorageUnitNotificationEventSync(notificationEventType, businessObjectDataKey, storageName, newStorageUnitStatus, oldStorageUnitStatus);

    // Return an AsyncResult so callers will know the future is "done". They can call "isDone" to know when this method has completed and they
    // can call "get" to see if any exceptions were thrown.
    return new AsyncResult<>(null);
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:18,代碼來源:NotificationEventServiceImpl.java

示例8: indexValidateAllTags

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
@Async
public Future<Void> indexValidateAllTags(String indexName)
{
    final String documentType = configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);

    // Get a list of all tags
    final List<TagEntity> tagEntityList = Collections.unmodifiableList(tagDao.getTags());

    // Remove any index documents that are not in the database
    removeAnyIndexDocumentsThatAreNotInTagsList(indexName, documentType, tagEntityList);

    // Validate all Tags
    tagHelper.executeFunctionForTagEntities(indexName, documentType, tagEntityList, indexFunctionsDao::validateDocumentIndex);

    // Return an AsyncResult so callers will know the future is "done". They can call "isDone" to know when this method has completed and they
    // can call "get" to see if any exceptions were thrown.
    return new AsyncResult<>(null);
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:20,代碼來源:TagServiceImpl.java

示例9: indexValidateAllBusinessObjectDefinitions

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
@Async
public Future<Void> indexValidateAllBusinessObjectDefinitions(String indexName)
{
    final String documentType = configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);

    // Get a list of all business object definitions
    final List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntityList =
        Collections.unmodifiableList(businessObjectDefinitionDao.getAllBusinessObjectDefinitions());

    // Remove any index documents that are not in the database
    removeAnyIndexDocumentsThatAreNotInBusinessObjectsDefinitionsList(indexName, documentType, businessObjectDefinitionEntityList);

    // Validate all Business Object Definitions
    businessObjectDefinitionHelper.executeFunctionForBusinessObjectDefinitionEntities(indexName, documentType, businessObjectDefinitionEntityList,
        indexFunctionsDao::validateDocumentIndex);

    // Return an AsyncResult so callers will know the future is "done". They can call "isDone" to know when this method has completed and they
    // can call "get" to see if any exceptions were thrown.
    return new AsyncResult<>(null);
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:22,代碼來源:BusinessObjectDefinitionServiceImpl.java

示例10: indexAllTags

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
@Async
public Future<Void> indexAllTags(SearchIndexKey searchIndexKey, String documentType)
{
    // Get a list of all tags
    final List<TagEntity> tagEntities = Collections.unmodifiableList(tagDao.getTags());

    // Index all tags.
    tagHelper.executeFunctionForTagEntities(searchIndexKey.getSearchIndexName(), documentType, tagEntities, indexFunctionsDao::createIndexDocument);

    // Simple count validation, index size should equal entity list size.
    validateSearchIndexSize(searchIndexKey.getSearchIndexName(), documentType, tagEntities.size());

    // Update search index status to READY.
    searchIndexDaoHelper.updateSearchIndexStatus(searchIndexKey, SearchIndexStatusEntity.SearchIndexStatuses.READY.name());

    // Return an AsyncResult so callers will know the future is "done". They can call "isDone" to know when this method has completed and they can call
    // "get" to see if any exceptions were thrown.
    return new AsyncResult<>(null);
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:21,代碼來源:SearchIndexHelperServiceImpl.java

示例11: createVimInstance

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Test
public void createVimInstance()
    throws VimException, PluginException, IOException, BadRequestException,
        AlreadyExistingException, ExecutionException, InterruptedException {
  OpenstackVimInstance datacenter = new OpenstackVimInstance();
  datacenter.setId("123");
  datacenter.setName("DC-1");
  datacenter.setType("OpenStack");
  datacenter.setUsername("datacenter_test");
  datacenter.setTenant("tenant");
  datacenter.setKeyPair("keypair");
  datacenter.setPassword("");
  when(mock.add(any(datacenter.getClass()), anyString()))
      .thenReturn(new AsyncResult<>(datacenter));
  log.info("" + restVimInstances.create(datacenter, "pi"));
  BaseVimInstance datacenter2 = restVimInstances.create(datacenter, "pi");
  assertEquals(datacenter, datacenter2);
}
 
開發者ID:openbaton,項目名稱:NFVO,代碼行數:19,代碼來源:ApiRestBaseVimInstancesTest.java

示例12: requestLog

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
@Async
public Future<NFVMessage> requestLog(VirtualNetworkFunctionRecord vnfr, String hostname)
    throws NotFoundException, BadFormatException, ExecutionException, InterruptedException {
  VnfmManagerEndpoint endpoint = generator.getVnfm(vnfr.getEndpoint());
  if (endpoint == null)
    throw new NotFoundException(
        "VnfManager of type "
            + vnfr.getType()
            + " (endpoint = "
            + vnfr.getEndpoint()
            + ") is not registered");

  OrVnfmLogMessage orVnfmLogMessage = new OrVnfmLogMessage(vnfr.getName(), hostname);
  VnfmSender vnfmSender;
  try {
    vnfmSender = generator.getVnfmSender(endpoint.getEndpointType());
  } catch (BeansException e) {
    throw new NotFoundException(e);
  }
  Future<NFVMessage> answerFuture = vnfmSender.sendCommand(orVnfmLogMessage, endpoint);
  answerFuture.get();
  NFVMessage message = answerFuture.get();
  return new AsyncResult<>(message);
}
 
開發者ID:openbaton,項目名稱:NFVO,代碼行數:26,代碼來源:VnfmManager.java

示例13: handleVNF

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
@Async
public Future<Void> handleVNF(
    NetworkServiceDescriptor networkServiceDescriptor,
    NetworkServiceRecord networkServiceRecord,
    DeployNSRBody body,
    Map<String, Set<String>> vduVimInstances,
    VirtualNetworkFunctionDescriptor vnfd,
    String monitoringIp)
    throws NotFoundException, BadFormatException, ExecutionException, InterruptedException {
  log.debug(
      "Processing VNFD ("
          + vnfd.getName()
          + ") for NSD ("
          + networkServiceDescriptor.getName()
          + ")");

  VnfmSender vnfmSender = generator.getVnfmSender(vnfd);
  NFVMessage message =
      generator.getNextMessage(vnfd, vduVimInstances, networkServiceRecord, body, monitoringIp);
  VnfmManagerEndpoint endpoint = generator.getEndpoint(vnfd);
  log.debug("----------Executing ACTION: " + message.getAction());
  executeAction(vnfmSender.sendCommand(message, endpoint));
  log.info("Sent " + message.getAction() + " to VNF: " + vnfd.getName());
  return new AsyncResult<>(null);
}
 
開發者ID:openbaton,項目名稱:NFVO,代碼行數:27,代碼來源:VnfStateHandler.java

示例14: send

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Override
@Async
public Future<Void> send(EventEndpoint endpoint, final ApplicationEventNFVO event) {

  log.debug("Sending message: " + event + " to endpoint: " + endpoint);
  log.info("Sending message: " + event.getAction() + " to endpoint: " + endpoint.getName());
  final String json =
      "{\"action\":\""
          + event.getAction()
          + "\",\"payload\":"
          + new Gson().toJson(event.getPayload())
          + "}";
  log.trace("Event body is: " + json);
  rabbitTemplate.convertAndSend(endpoint.getEndpoint(), json);

  return new AsyncResult<>(null);
}
 
開發者ID:openbaton,項目名稱:NFVO,代碼行數:18,代碼來源:RabbitEventSender.java

示例15: nsrManagementDeleteTest

import org.springframework.scheduling.annotation.AsyncResult; //導入依賴的package包/類
@Test
public void nsrManagementDeleteTest()
    throws VimException, InterruptedException, ExecutionException, NamingException,
        NotFoundException, WrongStatusException, PluginException, BadFormatException {
  NetworkServiceRecord nsd_exp = createNetworkServiceRecord();
  when(resourceManagement.release(any(VirtualDeploymentUnit.class), any(VNFCInstance.class)))
      .thenReturn(new AsyncResult<Void>(null));
  when(nsrRepository.findFirstByIdAndProjectId(nsd_exp.getId(), projectId)).thenReturn(nsd_exp);
  Configuration system = new Configuration();
  system.setConfigurationParameters(new HashSet<>());
  ConfigurationParameter configurationParameter = new ConfigurationParameter();
  configurationParameter.setConfKey("delete-on-all-status");
  configurationParameter.setValue("true");
  when(configurationManagement.queryByName("system")).thenReturn(system);
  nsrManagement.delete(nsd_exp.getId(), projectId);
}
 
開發者ID:openbaton,項目名稱:NFVO,代碼行數:17,代碼來源:NetworkServiceRecordManagementClassSuiteTest.java


注:本文中的org.springframework.scheduling.annotation.AsyncResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。