当 ignite 在 Opendaylight apache karaf 中作为服务启动时,如何为 apache ignite 设置自定义 REST 端口? [英] How to set custom REST port for apache ignite when ignite is started as a service in Opendaylight apache karaf?

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

问题描述

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

 System.setProperty("IGNITE_JETTY_PORT","7111");System.setProperty("IGNITE_JETTY_HOST","localhost");点燃 = Ignition.start(config);

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

解决方案

我觉得你可以试试ignite的配置xml文件

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

在 ignite-rest.xml 中它像:

<!--根据一项或多项授权给 Apache 软件基金会 (ASF)贡献者许可协议.请参阅随附的 NOTICE 文件这项工作以获取有关版权所有权的其他信息.ASF 根据 Apache 许可,版本 2.0 向您授予此文件的许可(许可证");除非符合以下规定,否则您不得使用此文件许可证.您可以在以下网址获取许可证副本http://www.apache.org/licenses/LICENSE-2.0除非适用法律要求或书面同意,否则软件根据许可证分发的分发是按原样"的基础分发的,不作任何形式的明示或暗示的保证或条件.请参阅许可证以了解管理权限的特定语言和许可证下的限制.--><!DOCTYPE Con​​figure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"><配置id="服务器"类="org.eclipse.jetty.server.Server"><Arg name="threadPool"><!-- 默认排队阻塞线程池--><New class="org.eclipse.jetty.util.thread.QueuedThreadPool"><Set name="minThreads">20</Set><Set name="maxThreads">200</Set></新的></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></新的><呼叫名称="addConnector"><Arg><New class="org.eclipse.jetty.server.ServerConnector"><Arg name="server"><Ref refid="Server"/></Arg><Arg><数组类型="org.eclipse.jetty.server.ConnectionFactory"><物品><New class="org.eclipse.jetty.server.HttpConnectionFactory"><Ref refid="httpCfg"/></新的></项目></阵列></Arg><!--请注意,为了覆盖本地主机和端口值,系统属性必须具有名称 IGNITE_JETTY_HOST 和IGNITE_JETTY_PORT 相应地.--><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></新的></Arg></呼叫><设置名称=处理程序"><New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"><设置名称=处理程序"><数组类型="org.eclipse.jetty.server.Handler"><物品><New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/></项目></阵列></设置></新的></设置><Set name="stopAtShutdown">false</Set></配置>

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

然后像这样开始点火:

ignite = Ignition.start(igniteConfigPath);

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);

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.

解决方案

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

<property name="ConnectorConfiguration.jettyPath" value="config/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,

and then start your ignite like:

ignite = Ignition.start(igniteConfigPath);

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆