本文介绍了在Opendaylight apache karaf中将ignite作为一项服务启动时,如何为apache ignite设置自定义REST端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Opendaylight使用端口8080,该端口与默认的ignite REST http端口相同.因此,我尝试更改ignite侦听REST请求的端口.这是用于此目的的Java代码段.

Opendaylight uses port 8080 which is the same as the default ignite REST http port. So i tried to change the port on which ignite listens for REST requests. Here is a java code snippet for this.

    System.setProperty("IGNITE_JETTY_PORT","7111");

    System.setProperty("IGNITE_JETTY_HOST","localhost"); 

    ignite = Ignition.start(config);

当我在eclipse中运行时,上面的方法工作正常并更改了点燃REST端口.但是当我在apache karaf中启动一个点燃实例时失败了.

The above works fine and changes the ignite REST port when i run in eclipse. But fails when i start an ignite instance in apache karaf.

推荐答案

我认为您可以尝试使用ignite的配置xml文件

I think you may try with the configuration xml file of ignite

<property name="ConnectorConfiguration.jettyPath" value="config/ignite-rest.xml"/>

并在ignite-rest.xml中如下所示:

and in the ignite-rest.xml it like:

<?xml version="1.0"?>

<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">
    <Arg name="threadPool">
        <!-- Default queued blocking thread pool -->
        <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
            <Set name="minThreads">20</Set>
            <Set name="maxThreads">200</Set>
        </New>
    </Arg>

    <New id="httpCfg" class="org.eclipse.jetty.server.HttpConfiguration">
        <Set name="secureScheme">https</Set>
        <Set name="securePort">8443</Set>
        <Set name="sendServerVersion">true</Set>
        <Set name="sendDateHeader">true</Set>
    </New>

    <Call name="addConnector">
        <Arg>
            <New class="org.eclipse.jetty.server.ServerConnector">
                <Arg name="server"><Ref refid="Server"/></Arg>
                <Arg>
                    <Array type="org.eclipse.jetty.server.ConnectionFactory">
                        <Item>
                            <New class="org.eclipse.jetty.server.HttpConnectionFactory">
                                <Ref refid="httpCfg"/>
                            </New>
                        </Item>
                    </Array>
                </Arg>
                <!--
                    Note that in order to override local host and port values,
                    system properties must have names IGNITE_JETTY_HOST and
                    IGNITE_JETTY_PORT accordingly.
                -->
                <Set name="host"><SystemProperty name="IGNITE_JETTY_HOST" default="localhost"/></Set>
                <Set name="port"><SystemProperty name="IGNITE_JETTY_PORT" default="9090"/></Set>
                <Set name="idleTimeout">30000</Set>
                <Set name="reuseAddress">true</Set>
            </New>
        </Arg>
    </Call>

    <Set name="handler">
        <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
            <Set name="handlers">
                <Array type="org.eclipse.jetty.server.Handler">
                    <Item>
                        <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
                    </Item>
                </Array>
            </Set>
        </New>
    </Set>

    <Set name="stopAtShutdown">false</Set>
</Configure>

您可以根据需要在配置文件中更改端口,

You could change the port in the configuration file as you like,

然后像这样开始点火:

ignite = Ignition.start(igniteConfigPath);

ignite = Ignition.start(igniteConfigPath);

这篇关于在Opendaylight apache karaf中将ignite作为一项服务启动时,如何为apache ignite设置自定义REST端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 18:12