当前位置: 首页>>代码示例>>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;未经允许,请勿转载。