当前位置: 首页>>代码示例>>Java>>正文


Java RestRequest.paramAsBoolean方法代码示例

本文整理汇总了Java中org.elasticsearch.rest.RestRequest.paramAsBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java RestRequest.paramAsBoolean方法的具体用法?Java RestRequest.paramAsBoolean怎么用?Java RestRequest.paramAsBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.rest.RestRequest的用法示例。


在下文中一共展示了RestRequest.paramAsBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateListTasksRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
public static ListTasksRequest generateListTasksRequest(RestRequest request) {
    boolean detailed = request.paramAsBoolean("detailed", false);
    String[] nodes = Strings.splitStringByCommaToArray(request.param("nodes"));
    String[] actions = Strings.splitStringByCommaToArray(request.param("actions"));
    TaskId parentTaskId = new TaskId(request.param("parent_task_id"));
    boolean waitForCompletion = request.paramAsBoolean("wait_for_completion", false);
    TimeValue timeout = request.paramAsTime("timeout", null);

    ListTasksRequest listTasksRequest = new ListTasksRequest();
    listTasksRequest.setNodes(nodes);
    listTasksRequest.setDetailed(detailed);
    listTasksRequest.setActions(actions);
    listTasksRequest.setParentTaskId(parentTaskId);
    listTasksRequest.setWaitForCompletion(waitForCompletion);
    listTasksRequest.setTimeout(timeout);
    return listTasksRequest;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RestListTasksAction.java

示例2: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    boolean helpWanted = request.paramAsBoolean("help", false);
    if (helpWanted) {
        return channel -> {
            Table table = getTableWithHeader(request);
            int[] width = buildHelpWidths(table, request);
            BytesStreamOutput bytesOutput = channel.bytesOutput();
            UTF8StreamWriter out = new UTF8StreamWriter().setOutput(bytesOutput);
            for (Table.Cell cell : table.getHeaders()) {
                // need to do left-align always, so create new cells
                pad(new Table.Cell(cell.value), width[0], request, out);
                out.append(" | ");
                pad(new Table.Cell(cell.attr.containsKey("alias") ? cell.attr.get("alias") : ""), width[1], request, out);
                out.append(" | ");
                pad(new Table.Cell(cell.attr.containsKey("desc") ? cell.attr.get("desc") : "not available"), width[2], request, out);
                out.append("\n");
            }
            out.close();
            channel.sendResponse(new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, bytesOutput.bytes()));
        };
    } else {
        return doCatRequest(request, client);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:AbstractCatAction.java

示例3: buildTable

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) {
    boolean fullId = req.paramAsBoolean("full_id", false);

    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);

    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        for (Map.Entry<String, String> attrEntry : node.getAttributes().entrySet()) {
            table.startRow();
            table.addCell(node.getName());
            table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().getId());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            table.addCell(node.getAddress().address().getPort());
            table.addCell(attrEntry.getKey());
            table.addCell(attrEntry.getValue());
            table.endRow();
        }
    }
    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RestNodeAttrsAction.java

示例4: handleRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    boolean detailed = request.paramAsBoolean("detailed", false);
    String[] nodesIds = Strings.splitStringByCommaToArray(request.param("node_id"));
    TaskId taskId = new TaskId(request.param("taskId"));
    String[] actions = Strings.splitStringByCommaToArray(request.param("actions"));
    TaskId parentTaskId = new TaskId(request.param("parent_task_id"));
    boolean waitForCompletion = request.paramAsBoolean("wait_for_completion", false);
    TimeValue timeout = request.paramAsTime("timeout", null);

    ListTasksRequest listTasksRequest = new ListTasksRequest();
    listTasksRequest.setTaskId(taskId);
    listTasksRequest.setNodesIds(nodesIds);
    listTasksRequest.setDetailed(detailed);
    listTasksRequest.setActions(actions);
    listTasksRequest.setParentTaskId(parentTaskId);
    listTasksRequest.setWaitForCompletion(waitForCompletion);
    listTasksRequest.setTimeout(timeout);
    client.admin().cluster().listTasks(listTasksRequest, new RestToXContentListener<ListTasksResponse>(channel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:RestListTasksAction.java

示例5: restContentBuilder

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
public static XContentBuilder restContentBuilder(RestRequest request)  
        throws IOException {
    XContentType contentType = XContentType  
            .fromRestContentType(request.header("Content-Type"));  
    if (contentType == null) {  
        // try and guess it from the body, if exists  
        if (request.hasContent()) {  
            contentType = XContentFactory.xContentType(request.content());  
        }  
    }  
    if (contentType == null) {  
        // default to JSON  
        contentType = XContentType.JSON;  
    }  
    BytesStreamOutput out = new BytesStreamOutput();  
    XContentBuilder builder = new XContentBuilder(  
            XContentFactory.xContent(contentType), out);  
  
    if (request.paramAsBoolean("pretty", false)) {  
        builder.prettyPrint();  
    }  
    String casing = request.param("case");  
    if (casing != null && "camelCase".equals(casing)) {  
        builder.fieldCaseConversion(  
                XContentBuilder.FieldCaseConversion.CAMELCASE);  
    } else {  
        builder.fieldCaseConversion(  
                XContentBuilder.FieldCaseConversion.NONE);  
    }  
    return builder;  
}
 
开发者ID:ghostboyzone,项目名称:ESAuthPlugin,代码行数:32,代码来源:ContentBuilder.java

示例6: doPrepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
protected RestChannelConsumer doPrepareRequest(RestRequest request, NodeClient client,
                                               boolean includeCreated, boolean includeUpdated) throws IOException {
    // Build the internal request
    Request internal = setCommonOptions(request, buildRequest(request));

    // Executes the request and waits for completion
    if (request.paramAsBoolean("wait_for_completion", true)) {
        Map<String, String> params = new HashMap<>();
        params.put(BulkByScrollTask.Status.INCLUDE_CREATED, Boolean.toString(includeCreated));
        params.put(BulkByScrollTask.Status.INCLUDE_UPDATED, Boolean.toString(includeUpdated));

        return channel -> client.executeLocally(action, internal, new BulkIndexByScrollResponseContentListener(channel, params));
    } else {
        internal.setShouldStoreResult(true);
    }

    /*
     * Let's try and validate before forking so the user gets some error. The
     * task can't totally validate until it starts but this is better than
     * nothing.
     */
    ActionRequestValidationException validationException = internal.validate();
    if (validationException != null) {
        throw validationException;
    }
    return sendTask(client.getLocalNodeId(), client.executeLocally(action, internal, LoggingTaskListener.instance()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:AbstractBaseReindexRestHandler.java

示例7: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    final String[] names = request.paramAsStringArrayOrEmptyIfAll("name");
    final boolean renderDefaults = request.paramAsBoolean("include_defaults", false);
    GetSettingsRequest getSettingsRequest = new GetSettingsRequest()
            .indices(Strings.splitStringByCommaToArray(request.param("index")))
            .indicesOptions(IndicesOptions.fromRequest(request, IndicesOptions.strictExpandOpen()))
            .humanReadable(request.hasParam("human"))
            .names(names);
    getSettingsRequest.local(request.paramAsBoolean("local", getSettingsRequest.local()));

    return channel -> client.admin().indices().getSettings(getSettingsRequest, new RestBuilderListener<GetSettingsResponse>(channel) {

        @Override
        public RestResponse buildResponse(GetSettingsResponse getSettingsResponse, XContentBuilder builder) throws Exception {
            builder.startObject();
            for (ObjectObjectCursor<String, Settings> cursor : getSettingsResponse.getIndexToSettings()) {
                // no settings, jump over it to shorten the response data
                if (cursor.value.isEmpty()) {
                    continue;
                }
                builder.startObject(cursor.key);
                builder.startObject("settings");
                cursor.value.toXContent(builder, request);
                builder.endObject();
                if (renderDefaults) {
                    builder.startObject("defaults");
                    settingsFilter.filter(indexScopedSettings.diff(cursor.value, settings)).toXContent(builder, request);
                    builder.endObject();
                }
                builder.endObject();
            }
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:RestGetSettingsAction.java

示例8: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest()
            .routingTable(false)
            .nodes(false);
    final boolean renderDefaults = request.paramAsBoolean("include_defaults", false);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestBuilderListener<ClusterStateResponse>(channel) {
        @Override
        public RestResponse buildResponse(ClusterStateResponse response, XContentBuilder builder) throws Exception {
            return new BytesRestResponse(RestStatus.OK, renderResponse(response.getState(), renderDefaults, builder, request));
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:RestClusterGetSettingsAction.java

示例9: prepareRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    TaskId taskId = new TaskId(request.param("taskId"));
    boolean waitForCompletion = request.paramAsBoolean("wait_for_completion", false);
    TimeValue timeout = request.paramAsTime("timeout", null);

    GetTaskRequest getTaskRequest = new GetTaskRequest();
    getTaskRequest.setTaskId(taskId);
    getTaskRequest.setWaitForCompletion(waitForCompletion);
    getTaskRequest.setTimeout(timeout);
    return channel -> client.admin().cluster().getTask(getTaskRequest, new RestToXContentListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:RestGetTaskAction.java

示例10: checkOutputTimestamp

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
static boolean checkOutputTimestamp(String disp, RestRequest request) {
    if (Table.TIMESTAMP.equals(disp) || Table.EPOCH.equals(disp)) {
        return request.paramAsBoolean("ts", true);
    } else {
        return true;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:RestTable.java

示例11: getTableWithHeader

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
protected Table getTableWithHeader(final RestRequest request) {
    boolean detailed = request.paramAsBoolean("detailed", false);
    Table table = new Table();
    table.startHeaders();

    // Task main info
    table.addCell("id", "default:false;desc:id of the task with the node");
    table.addCell("action", "alias:ac;desc:task action");
    table.addCell("task_id", "alias:ti;desc:unique task id");
    table.addCell("parent_task_id", "alias:pti;desc:parent task id");
    table.addCell("type", "alias:ty;desc:task type");
    table.addCell("start_time", "alias:start;desc:start time in ms");
    table.addCell("timestamp", "alias:ts,hms,hhmmss;desc:start time in HH:MM:SS");
    table.addCell("running_time_ns", "default:false;alias:time;desc:running time ns");
    table.addCell("running_time", "default:true;alias:time;desc:running time");

    // Node info
    table.addCell("node_id", "default:false;alias:ni;desc:unique node id");
    table.addCell("ip", "default:true;alias:i;desc:ip address");
    table.addCell("port", "default:false;alias:po;desc:bound transport port");
    table.addCell("node", "default:true;alias:n;desc:node name");
    table.addCell("version", "default:false;alias:v;desc:es version");

    // Task detailed info
    if (detailed) {
        table.addCell("description", "default:true;alias:desc;desc:task action");
    }
    table.endHeaders();
    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:RestTasksAction.java

示例12: buildTable

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
private Table buildTable(RestRequest request, ListTasksResponse listTasksResponse) {
    boolean fullId = request.paramAsBoolean("full_id", false);
    boolean detailed = request.paramAsBoolean("detailed", false);
    Table table = getTableWithHeader(request);
    buildGroups(table, fullId, detailed, listTasksResponse.getTaskGroups());
    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:RestTasksAction.java

示例13: doCatRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
    final boolean fullId = request.paramAsBoolean("full_id", false);
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(true).os(true).process(true).http(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true).process(true).script(true);
                    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
                        @Override
                        public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
                            return RestTable.buildResponse(buildTable(fullId, request, clusterStateResponse, nodesInfoResponse,
                                nodesStatsResponse), channel);
                        }
                    });
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:RestNodesAction.java

示例14: prepareGetRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
private RestChannelConsumer prepareGetRequest(final RestRequest request) {
    final String index = request.param("index");
    final int from = request.paramAsInt("from", 0);
    final int size = request.paramAsInt("size", 10);
    final boolean pretty = request.paramAsBoolean("pretty", false);
    return channel -> {
        if (index == null || index.trim().length() == 0) {
            indexingProxyService.getRequestSenderInfos(from, size,
                    wrap(res -> sendResponse(channel, res, pretty), e -> sendErrorResponse(channel, e)));
        } else {
            indexingProxyService.getRequestSenderInfo(index,
                    wrap(res -> sendResponse(channel, res, pretty), e -> sendErrorResponse(channel, e)));
        }
    };
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:16,代码来源:RestIndexingProxyProcessAction.java

示例15: preparePostRequest

import org.elasticsearch.rest.RestRequest; //导入方法依赖的package包/类
private RestChannelConsumer preparePostRequest(final RestRequest request) {
    final String index = request.param("index");
    final long position = request.paramAsLong("position", 0);
    final boolean pretty = request.paramAsBoolean("pretty", false);
    return channel -> {
        indexingProxyService.startRequestSender(index, position,
                wrap(res -> sendResponse(channel, res, pretty), e -> sendErrorResponse(channel, e)));
    };
}
 
开发者ID:codelibs,项目名称:elasticsearch-indexing-proxy,代码行数:10,代码来源:RestIndexingProxyProcessAction.java


注:本文中的org.elasticsearch.rest.RestRequest.paramAsBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。