【问题标题】:How to set custom REST port for apache ignite when ignite is started as a service in Opendaylight apache karaf?当 ignite 在 Opendaylight apache karaf 中作为服务启动时,如何为 apache ignite 设置自定义 REST 端口?
【发布时间】:2018-04-16 15:25:30
【问题描述】:

Opendaylight 使用端口 8080,与默认的 ignite REST http 端口相同。因此,我尝试更改 ignite 侦听 REST 请求的端口。这是一个java代码sn-p。

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

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

    ignite = Ignition.start(config);

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

【问题讨论】:

  • 可能是您的端口不可用或 dns 服务器无法解析“localhost”。能否请您提供 apach ignite 的失败日志以供调查?

标签: ignite apache-karaf opendaylight


【解决方案1】:

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

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

并且在 ignite-rest.xml 中是这样的:

<?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>

你可以随意更改配置文件中的端口,

然后像这样开始你的点燃:

ignite = Ignition.start(igniteConfigPath);

【讨论】:

  • 谢谢。您的解决方案现在正在运行。问题是我得到了一个“ClassNotFound”异常,因为 ignite-core jar 无法从 ignite-rest-http 访问一个类。
【解决方案2】:

如果有帮助,您可以更改 OpenDaylight 的 NB REST 端口。参见 puppet-opendaylight (docs, config logic) 等上游配置管理工具提供的示例。

【讨论】:

    猜你喜欢
    • 2022-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-17
    • 1970-01-01
    • 1970-01-01
    • 2018-03-03
    相关资源
    最近更新 更多