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


Java CopyOnWriteArrayList.get方法代碼示例

本文整理匯總了Java中java.util.concurrent.CopyOnWriteArrayList.get方法的典型用法代碼示例。如果您正苦於以下問題:Java CopyOnWriteArrayList.get方法的具體用法?Java CopyOnWriteArrayList.get怎麽用?Java CopyOnWriteArrayList.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.concurrent.CopyOnWriteArrayList的用法示例。


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

示例1: finishAndNotifyListener

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) {
    logger.trace("{}: got all shard responses", actionName);
    int successfulShards = 0;
    int failedShards = 0;
    int totalNumCopies = 0;
    List<ShardOperationFailedException> shardFailures = null;
    for (int i = 0; i < shardsResponses.size(); i++) {
        ReplicationResponse shardResponse = shardsResponses.get(i);
        if (shardResponse == null) {
            // non active shard, ignore
        } else {
            failedShards += shardResponse.getShardInfo().getFailed();
            successfulShards += shardResponse.getShardInfo().getSuccessful();
            totalNumCopies += shardResponse.getShardInfo().getTotal();
            if (shardFailures == null) {
                shardFailures = new ArrayList<>();
            }
            for (ReplicationResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) {
                shardFailures.add(new DefaultShardOperationFailedException(new BroadcastShardOperationFailedException(failure.fullShardId(), failure.getCause())));
            }
        }
    }
    listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,代碼來源:TransportBroadcastReplicationAction.java

示例2: finishAndNotifyListener

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
private void finishAndNotifyListener(ActionListener listener, CopyOnWriteArrayList<ShardResponse> shardsResponses) {
    logger.trace("{}: got all shard responses", actionName);
    int successfulShards = 0;
    int failedShards = 0;
    int totalNumCopies = 0;
    List<ShardOperationFailedException> shardFailures = null;
    for (int i = 0; i < shardsResponses.size(); i++) {
        ActionWriteResponse shardResponse = shardsResponses.get(i);
        if (shardResponse == null) {
            // non active shard, ignore
        } else {
            failedShards += shardResponse.getShardInfo().getFailed();
            successfulShards += shardResponse.getShardInfo().getSuccessful();
            totalNumCopies += shardResponse.getShardInfo().getTotal();
            if (shardFailures == null) {
                shardFailures = new ArrayList<>();
            }
            for (ActionWriteResponse.ShardInfo.Failure failure : shardResponse.getShardInfo().getFailures()) {
                shardFailures.add(new DefaultShardOperationFailedException(new BroadcastShardOperationFailedException(new ShardId(failure.index(), failure.shardId()), failure.getCause())));
            }
        }
    }
    listener.onResponse(newResponse(successfulShards, failedShards, totalNumCopies, shardFailures));
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:25,代碼來源:TransportBroadcastReplicationAction.java

示例3: getContentByCourse

import java.util.concurrent.CopyOnWriteArrayList; //導入方法依賴的package包/類
/**
 * Method to get all contents of a given course.
 */
@SuppressWarnings("unchecked")
private Response getContentByCourse(String userId, Map<String, Object> request) {

  Response response = null;
  Util.DbInfo dbInfo = Util.dbInfoMap.get(JsonKey.LEARNER_CONTENT_DB);

  if (request.get(JsonKey.COURSE) != null) {
    Map<String, Object> courseMap = (Map<String, Object>) request.get(JsonKey.COURSE);
    String courseId = (String) courseMap.get(JsonKey.COURSE_ID);
    CopyOnWriteArrayList<String> contentIds =
        new CopyOnWriteArrayList<String>((List<String>) courseMap.get(JsonKey.CONTENT_IDS));
    LinkedHashMap<String, Object> queryMap = new LinkedHashMap<String, Object>();
    queryMap.put(JsonKey.USER_ID, userId);
    queryMap.put(JsonKey.COURSE_ID, courseId);
    response = cassandraOperation.getRecordsByProperties(dbInfo.getKeySpace(),
        dbInfo.getTableName(), queryMap);
    List<Map<String, Object>> modifiedContentList = new ArrayList<Map<String, Object>>();
    List<Map<String, Object>> resultedList =
        (List<Map<String, Object>>) response.getResult().get(JsonKey.RESPONSE);

    if (null != contentIds && !(contentIds.isEmpty())) {

      for (Map<String, Object> map : resultedList) {
        boolean flag = true;
        for (int i = 0; i < contentIds.size() && flag; i++) {
          String contentId = contentIds.get(i);
          if (contentId.equals((String) map.get(JsonKey.CONTENT_ID))) {
            modifiedContentList.add(map);
            flag = false;
          }
        }
      }
      response.getResult().put(JsonKey.RESPONSE, modifiedContentList);
    }
  }
  return response;
}
 
開發者ID:project-sunbird,項目名稱:sunbird-lms-mw,代碼行數:41,代碼來源:LearnerStateActor.java


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