新闻资讯

新闻资讯 媒体报道

Java Tuple类代码示例

编辑:016     时间:2021-12-15

Java Tuple类代码示例

本文整理汇总了Java中org.elasticsearch.common.collect.Tuple类的典型用法代码示例。如果您正苦于以下问题:Java Tuple类的具体用法?Java Tuple怎么用?Java Tuple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

Tuple类属于org.elasticsearch.common.collect包,在下文中一共展示了Tuple类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testToAndFromXContent

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testToAndFromXContent() throws Exception {
    XContentType xContentType = randomFrom(XContentType.values()); Tuple<GetResult, GetResult> tuple = randomGetResult(xContentType);
    GetResponse getResponse = new GetResponse(tuple.v1());
    GetResponse expectedGetResponse = new GetResponse(tuple.v2()); boolean humanReadable = randomBoolean();
    BytesReference originalBytes = toXContent(getResponse, xContentType, humanReadable); //test that we can parse what we print out GetResponse parsedGetResponse; try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) {
        parsedGetResponse = GetResponse.fromXContent(parser);
        assertNull(parser.nextToken());
    }
    assertEquals(expectedGetResponse, parsedGetResponse); //print the parsed object out and test that the output is the same as the original output BytesReference finalBytes = toXContent(parsedGetResponse, xContentType, humanReadable);
    assertToXContentEquivalent(originalBytes, finalBytes, xContentType); //check that the source stays unchanged, no shuffling of keys nor anything like that assertEquals(expectedGetResponse.getSourceAsString(), parsedGetResponse.getSourceAsString());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:GetResponseTests.java

示例2: testUpgradeIndices

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testUpgradeIndices() throws IOException { final Settings nodeSettings = Settings.builder()
        .put(NodeEnvironment.ADD_NODE_LOCK_ID_TO_CUSTOM_PATH.getKey(), randomBoolean()).build(); try (NodeEnvironment nodeEnv = newNodeEnvironment(nodeSettings)) {
        Map<IndexSettings, Tuple<Integer, Integer>>  indexSettingsMap = new HashMap<>(); for (int i = 0; i < randomIntBetween(2, 5); i++) { final Index index = new Index(randomAsciiOfLength(10), UUIDs.randomBase64UUID());
            Settings settings = Settings.builder()
                .put(nodeSettings)
                .put(IndexMetaData.SETTING_INDEX_UUID, index.getUUID())
                .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_0_0)
                .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 5))
                .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
                .build();
            IndexMetaData indexState = IndexMetaData.builder(index.getName()).settings(settings).build(); Tuple<Integer, Integer> fileCounts = new Tuple<>(randomIntBetween(1, 5), randomIntBetween(1, 5));
            IndexSettings indexSettings = new IndexSettings(indexState, nodeSettings);
            indexSettingsMap.put(indexSettings, fileCounts);
            writeIndex(nodeEnv, indexSettings, fileCounts.v1(), fileCounts.v2());
        }
        IndexFolderUpgrader.upgradeIndicesIfNeeded(nodeSettings, nodeEnv); for (Map.Entry<IndexSettings, Tuple<Integer, Integer>> entry : indexSettingsMap.entrySet()) {
            checkIndex(nodeEnv, entry.getKey(), entry.getValue().v1(), entry.getValue().v2());
        }
    }
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:IndexFolderUpgraderTests.java

示例3: testParseTwoSettingsExplicitDefault

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testParseTwoSettingsExplicitDefault() {
    Settings settings = Settings.builder()
            .put("cloud.azure.storage.azure1.account", "myaccount1")
            .put("cloud.azure.storage.azure1.key", "mykey1")
            .put("cloud.azure.storage.azure1.default", true)
            .put("cloud.azure.storage.azure2.account", "myaccount2")
            .put("cloud.azure.storage.azure2.key", "mykey2")
            .build(); Tuple<AzureStorageSettings, Map<String, AzureStorageSettings>> tuple = AzureStorageSettings.parse(settings);
    assertThat(tuple.v1(), notNullValue());
    assertThat(tuple.v1().getAccount(), is("myaccount1"));
    assertThat(tuple.v1().getKey(), is("mykey1"));
    assertThat(tuple.v2().keySet(), hasSize(1));
    assertThat(tuple.v2().get("azure2"), notNullValue());
    assertThat(tuple.v2().get("azure2").getAccount(), is("myaccount2"));
    assertThat(tuple.v2().get("azure2").getKey(), is("mykey2"));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:AzureSettingsParserTests.java

示例4: testExistingConfig

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testExistingConfig() throws Exception { Tuple<Path, Environment> env = createEnv(fs, temp);
    Path envConfigDir = env.v2().configFile().resolve("fake");
    Files.createDirectories(envConfigDir);
    Files.write(envConfigDir.resolve("custom.yaml"), "existing config".getBytes(StandardCharsets.UTF_8));
    Path pluginDir = createPluginDir(temp);
    Path configDir = pluginDir.resolve("config");
    Files.createDirectory(configDir);
    Files.write(configDir.resolve("custom.yaml"), "new config".getBytes(StandardCharsets.UTF_8));
    Files.createFile(configDir.resolve("other.yaml"));
    String pluginZip = createPlugin("fake", pluginDir);
    installPlugin(pluginZip, env.v1());
    assertPlugin("fake", pluginDir, env.v2());
    List<String> configLines = Files.readAllLines(envConfigDir.resolve("custom.yaml"), StandardCharsets.UTF_8);
    assertEquals(1, configLines.size());
    assertEquals("existing config", configLines.get(0));
    assertTrue(Files.exists(envConfigDir.resolve("other.yaml")));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:InstallPluginCommandTests.java

示例5: testNotStartedPrimary

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testNotStartedPrimary() throws InterruptedException, ExecutionException, IOException { final String index = "test";
    setState(clusterService, state(index, randomBoolean(),
            randomBoolean() ? ShardRoutingState.INITIALIZING : ShardRoutingState.UNASSIGNED, ShardRoutingState.UNASSIGNED));
    logger.debug("--> using initial state:\n{}", clusterService.state());
    Future<BroadcastResponse> response = (broadcastReplicationAction.execute(new DummyBroadcastRequest().indices(index))); for (Tuple<ShardId, ActionListener<ReplicationResponse>> shardRequests : broadcastReplicationAction.capturedShardRequests) { if (randomBoolean()) {
            shardRequests.v2().onFailure(new NoShardAvailableActionException(shardRequests.v1()));
        } else {
            shardRequests.v2().onFailure(new UnavailableShardsException(shardRequests.v1(), "test exception"));
        }
    }
    response.get();
    logger.info("total shards: {}, ", response.get().getTotalShards()); // we expect no failures here because UnavailableShardsException does not count as failed assertBroadcastResponse(2, 0, 0, response.get(), null);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:BroadcastReplicationTests.java

示例6: writeOperation

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 /**
 * 
 * @param operation
 * @return * @throws IOException 
 */ public Tuple<Future<DLSN>, Tuple<BytesReference, Long>> writeOperation(Translog.Operation operation, AtomicLong txid) throws IOException {
    BytesStreamOutput out = new BytesStreamOutput(); try (ReleasableLock lock = writeLock.acquire()) {
        Future<DLSN> writeResult = null;
        out.writeByte(operation.opType().id());
        operation.writeTo(out);
        BytesReference bytes = out.bytes();
        LogRecord logRecord = new LogRecord(txid.incrementAndGet(), bytes.toBytes());
        writeResult = logWriter.write(logRecord);
        sizeInBytes += (20 + logRecord.getPayload().length);
        ++ numOperations; return new Tuple<Future<DLSN>, Tuple<BytesReference, Long>>(writeResult, new Tuple<BytesReference, Long>(bytes, txid.get()));
    } catch (TransactionIdOutOfOrderException e) { throw e;
    } finally {
        out.close();
    }
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:DistributedTranslog.java

示例7: AzureStorageServiceImpl

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public AzureStorageServiceImpl(Settings settings) { super(settings); Tuple<AzureStorageSettings, Map<String, AzureStorageSettings>> storageSettings = AzureStorageSettings.parse(settings); this.primaryStorageSettings = storageSettings.v1(); this.secondariesStorageSettings = storageSettings.v2(); this.clients = new HashMap<>();

    logger.debug("starting azure storage client instance"); // We register the primary client if any if (primaryStorageSettings != null) {
        logger.debug("registering primary client for account [{}]", primaryStorageSettings.getAccount());
        createClient(primaryStorageSettings);
    } // We register all secondary clients for (Map.Entry<String, AzureStorageSettings> azureStorageSettingsEntry : secondariesStorageSettings.entrySet()) {
        logger.debug("registering secondary client for account [{}]", azureStorageSettingsEntry.getKey());
        createClient(azureStorageSettingsEntry.getValue());
    }
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:AzureStorageServiceImpl.java

示例8: testMasterNodeOperationTasks

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testMasterNodeOperationTasks() {
    registerTaskManageListeners(ClusterHealthAction.NAME); // First run the health on the master node - should produce only one task on the master node internalCluster().masterClient().admin().cluster().prepareHealth().get();
    assertEquals(1, numberOfEvents(ClusterHealthAction.NAME, Tuple::v1)); // counting only registration events assertEquals(1, numberOfEvents(ClusterHealthAction.NAME, event -> event.v1() == false)); // counting only unregistration events resetTaskManageListeners(ClusterHealthAction.NAME); // Now run the health on a non-master node - should produce one task on master and one task on another node internalCluster().nonMasterClient().admin().cluster().prepareHealth().get();
    assertEquals(2, numberOfEvents(ClusterHealthAction.NAME, Tuple::v1)); // counting only registration events assertEquals(2, numberOfEvents(ClusterHealthAction.NAME, event -> event.v1() == false)); // counting only unregistration events List<TaskInfo> tasks = findEvents(ClusterHealthAction.NAME, Tuple::v1); // Verify that one of these tasks is a parent of another task if (tasks.get(0).getParentTaskId().isSet()) {
        assertParentTask(Collections.singletonList(tasks.get(0)), tasks.get(1));
    } else {
        assertParentTask(Collections.singletonList(tasks.get(1)), tasks.get(0));
    }
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:TasksIT.java

示例9: shardOperationOnPrimary

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 @Override protected Tuple<IndexResponse, IndexRequest> shardOperationOnPrimary(MetaData metaData, IndexRequest request) throws Throwable { // validate, if routing is required, that we got routing IndexMetaData indexMetaData = metaData.index(request.shardId().getIndex());
    MappingMetaData mappingMd = indexMetaData.mappingOrDefault(request.type()); if (mappingMd != null && mappingMd.routing().required()) { if (request.routing() == null) { throw new RoutingMissingException(request.shardId().getIndex(), request.type(), request.id());
        }
    }

    IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex());
    IndexShard indexShard = indexService.shardSafe(request.shardId().id());
    indexShard.checkDiskSpace(fsService); final WriteResult<IndexResponse> result = executeIndexRequestOnPrimary(null, request, indexShard, mappingUpdatedAction); final IndexResponse response = result.response; final Translog.Location location = result.location;
    processAfterWrite(request.refresh(), indexShard, location); return new Tuple<>(response, request);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:TransportIndexAction.java

示例10: updatedSettings

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public Settings updatedSettings() {
    Map<String, String> foundSettings = new HashMap<>(); final Settings.Builder builder = Settings.builder(); for (Tuple<PluginInfo, Plugin> plugin : plugins) {
        Settings settings = plugin.v2().additionalSettings(); for (String setting : settings.getAsMap().keySet()) {
            String oldPlugin = foundSettings.put(setting, plugin.v1().getName()); if (oldPlugin != null) { throw new IllegalArgumentException("Cannot have additional setting [" + setting + "] " + "in plugin [" + plugin.v1().getName() + "], already added in plugin [" + oldPlugin + "]");
            }
        }
        builder.put(settings);
    } return builder.put(this.settings).build();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:PluginsService.java

示例11: testTransportReplicationAllShardsTasks

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testTransportReplicationAllShardsTasks() {
    registerTaskManageListeners(FieldStatsAction.NAME); // main task registerTaskManageListeners(FieldStatsAction.NAME + "[s]"); // shard level tasks createIndex("test");
    ensureGreen("test"); // Make sure all shards are allocated client().prepareFieldStats().setFields("field").get(); // the field stats operation should produce one main task NumShards numberOfShards = getNumShards("test");
    assertEquals(1, numberOfEvents(FieldStatsAction.NAME, Tuple::v1)); // and then one operation per shard assertEquals(numberOfShards.numPrimaries, numberOfEvents(FieldStatsAction.NAME + "[s]", Tuple::v1)); // the shard level tasks should have the main task as a parent assertParentTask(findEvents(FieldStatsAction.NAME + "[s]", Tuple::v1), findEvents(FieldStatsAction.NAME, Tuple::v1).get(0));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:TasksIT.java

示例12: moveShards

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 /**
 * Move started shards that can not be allocated to a node anymore
 *
 * For each shard to be moved this function executes a move operation
 * to the minimal eligible node with respect to the
 * weight function. If a shard is moved the shard will be set to
 * {@link ShardRoutingState#RELOCATING} and a shadow instance of this
 * shard is created with an incremented version in the state
 * {@link ShardRoutingState#INITIALIZING}.
 */ public void moveShards() { // Iterate over the started shards interleaving between nodes, and check if they can remain. In the presence of throttling // shard movements, the goal of this iteration order is to achieve a fairer movement of shards from the nodes that are // offloading the shards. for (Iterator<ShardRouting> it = allocation.routingNodes().nodeInterleavedShardIterator(); it.hasNext(); ) {
        ShardRouting shardRouting = it.next(); final MoveDecision moveDecision = decideMove(shardRouting); if (moveDecision.isDecisionTaken() && moveDecision.forceMove()) { final ModelNode sourceNode = nodes.get(shardRouting.currentNodeId()); final ModelNode targetNode = nodes.get(moveDecision.getTargetNode().getId());
            sourceNode.removeShard(shardRouting); Tuple<ShardRouting, ShardRouting> relocatingShards = routingNodes.relocateShard(shardRouting, targetNode.getNodeId(),
                allocation.clusterInfo().getShardSize(shardRouting, ShardRouting.UNAVAILABLE_EXPECTED_SHARD_SIZE), allocation.changes());
            targetNode.addShard(relocatingShards.v2()); if (logger.isTraceEnabled()) {
                logger.trace("Moved shard [{}] to node [{}]", shardRouting, targetNode.getRoutingNode());
            }
        } else if (moveDecision.isDecisionTaken() && moveDecision.canRemain() == false) {
            logger.trace("[{}][{}] can't move", shardRouting.index(), shardRouting.id());
        }
    }
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:BalancedShardsAllocator.java

示例13: testRebalancingNotAllowedDueToCanAllocate

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testRebalancingNotAllowedDueToCanAllocate() {
    AllocationDecider canAllocateDecider = new AllocationDecider(Settings.EMPTY) { @Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { return Decision.NO;
        }
    }; Tuple<ClusterState, MoveDecision> rebalance = setupStateAndRebalance(canAllocateDecider, Settings.EMPTY, false);
    ClusterState clusterState = rebalance.v1();
    MoveDecision rebalanceDecision = rebalance.v2();
    assertEquals(Type.YES, rebalanceDecision.getClusterRebalanceDecision().type());
    assertEquals(AllocationDecision.NO, rebalanceDecision.getAllocationDecision());
    assertThat(rebalanceDecision.getExplanation(), startsWith( "cannot rebalance as no target node exists that can both allocate this shard and improve the cluster balance"));
    assertEquals(clusterState.nodes().getSize() - 1, rebalanceDecision.getNodeDecisions().size());
    assertNull(rebalanceDecision.getTargetNode()); int prevRanking = 0; for (NodeAllocationResult result : rebalanceDecision.getNodeDecisions()) {
        assertThat(result.getWeightRanking(), greaterThanOrEqualTo(prevRanking));
        prevRanking = result.getWeightRanking();
    }
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:BalancedSingleShardTests.java

示例14: validate

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 /**
 * Validates that the setting is valid
 */ public final void validate(String key, Settings settings) {
    Setting setting = get(key); if (setting == null) {
        LevensteinDistance ld = new LevensteinDistance();
        List<Tuple<Float, String>> scoredKeys = new ArrayList<>(); for (String k : this.keySettings.keySet()) { float distance = ld.getDistance(key, k); if (distance > 0.7f) {
                scoredKeys.add(new Tuple<>(distance, k));
            }
        }
        CollectionUtil.timSort(scoredKeys, (a,b) -> b.v1().compareTo(a.v1()));
        String msgPrefix = "unknown setting";
        SecureSettings secureSettings = settings.getSecureSettings(); if (secureSettings != null && settings.getSecureSettings().getSettingNames().contains(key)) {
            msgPrefix = "unknown secure setting";
        }
        String msg = msgPrefix + " [" + key + "]";
        List<String> keys = scoredKeys.stream().map((a) -> a.v2()).collect(Collectors.toList()); if (keys.isEmpty() == false) {
            msg += " did you mean " + (keys.size() == 1 ? "[" + keys.get(0) + "]": "any of " + keys.toString()) + "?";
        } else {
            msg += " please check that any required plugins are installed, or check the breaking changes documentation for removed " + "settings";
        } throw new IllegalArgumentException(msg);
    }
    setting.get(settings);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:AbstractScopedSettings.java

示例15: testRandomValidCombinations

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testRandomValidCombinations() {
    List<Tuple<String, Integer>> cases = new ArrayList<>(); // random number of strings with valid octets and valid network masks for (int i = 0; i < randomIntBetween(1, 1024); i++) { int networkMask = randomIntBetween(0, 32); long mask = (1L << (32 - networkMask)) - 1; long address = randomLongInIPv4Range() & ~mask;
        cases.add(new Tuple<>(Cidrs.octetsToCIDR(Cidrs.longToOctets(address), networkMask), networkMask));
    } for (Tuple<String, Integer> test : cases) { long[] actual = Cidrs.cidrMaskToMinMax(test.v1());
        assertNotNull(test.v1(), actual);
        assertEquals(test.v1(), 2, actual.length); // assert the resulting block has the right size assertEquals(test.v1(), 1L << (32 - test.v2()), actual[1] - actual[0]);
    }
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:CidrsTests.java

示例16: testThrowableToAndFromXContent

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testThrowableToAndFromXContent() throws IOException { final XContent xContent = randomFrom(XContentType.values()).xContent(); final Tuple<Throwable, ElasticsearchException> exceptions = randomExceptions(); final Throwable throwable = exceptions.v1();

    BytesReference throwableBytes = XContentHelper.toXContent((builder, params) -> {
        ElasticsearchException.generateThrowableXContent(builder, params, throwable); return builder;
    }, xContent.type(), randomBoolean());

    ElasticsearchException parsedException; try (XContentParser parser = createParser(xContent, throwableBytes)) {
        assertEquals(XContentParser.Token.START_OBJECT, parser.nextToken());
        parsedException = ElasticsearchException.fromXContent(parser);
        assertEquals(XContentParser.Token.END_OBJECT, parser.currentToken());
        assertNull(parser.nextToken());
    }
    assertDeepEquals(exceptions.v2(), parsedException);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ElasticsearchExceptionTests.java

示例17: shardOperationOnPrimary

 点赞 3 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 @Override protected Tuple<PutChunkResponse, PutChunkReplicaRequest> shardOperationOnPrimary(MetaData metaData,
                                                                                  PutChunkRequest request) throws Throwable {
    PutChunkResponse response = newResponseInstance();
    transferTarget.continueTransfer(request, response); final PutChunkReplicaRequest replicaRequest = new PutChunkReplicaRequest();
    replicaRequest.setShardId(request.shardId());
    replicaRequest.transferId = request.transferId();
    replicaRequest.sourceNodeId = clusterService.localNode().id();
    replicaRequest.currentPos = request.currentPos();
    replicaRequest.content = request.content();
    replicaRequest.isLast = request.isLast();
    replicaRequest.index(request.index()); return new Tuple<>(response, replicaRequest);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:TransportPutChunkAction.java

示例18: shardOperationOnReplica

 点赞 2 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 @Override protected void shardOperationOnReplica(final R shardRequest) {
    KillableCallable<Tuple> callable = new KillableWrapper() { @Override public Tuple call() throws Exception {
            processRequestItemsOnReplica(shardRequest.shardId(), shardRequest); return null;
        }
    };
    wrapOperationInKillable(shardRequest, callable);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:TransportShardAction.java

示例19: processRequestsWithBody

 点赞 2 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 private Collection<FullHttpResponse> processRequestsWithBody(HttpMethod method, SocketAddress remoteAddress, Tuple<String,
    CharSequence>... urisAndBodies) throws InterruptedException {
    Collection<HttpRequest> requests = new ArrayList<>(urisAndBodies.length); for (Tuple<String, CharSequence> uriAndBody : urisAndBodies) {
        ByteBuf content = Unpooled.copiedBuffer(uriAndBody.v2(), StandardCharsets.UTF_8);
        HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, uriAndBody.v1(), content);
        request.headers().add(HttpHeaderNames.HOST, "localhost");
        request.headers().add(HttpHeaderNames.CONTENT_LENGTH, content.readableBytes());
        request.headers().add(HttpHeaderNames.CONTENT_TYPE, "application/json");
        requests.add(request);
    } return sendRequests(remoteAddress, requests);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:Netty4HttpClient.java

示例20: testSpaceInUrl

 点赞 2 
import org.elasticsearch.common.collect.Tuple; //导入依赖的package包/类 public void testSpaceInUrl() throws Exception { Tuple<Path, Environment> env = createEnv(fs, temp);
    Path pluginDir = createPluginDir(temp);
    String pluginZip = createPlugin("fake", pluginDir);
    Path pluginZipWithSpaces = createTempFile("foo bar", ".zip"); try (InputStream in = FileSystemUtils.openFileURLStream(new URL(pluginZip))) {
        Files.copy(in, pluginZipWithSpaces, StandardCopyOption.REPLACE_EXISTING);
    }
    installPlugin(pluginZipWithSpaces.toUri().toURL().toString(), env.v1());
    assertPlugin("fake", pluginDir, env.v2());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:InstallPluginCommandTests.java
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

回复列表

相关推荐