brooklyn.util.net.Networking.checkPortsValid()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中brooklyn.util.net.Networking.checkPortsValid()方法的一些代码示例,展示了Networking.checkPortsValid()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Networking.checkPortsValid()方法的具体详情如下:
包路径:brooklyn.util.net.Networking
类名称:Networking
方法名:checkPortsValid

Networking.checkPortsValid介绍

暂无

代码示例

代码示例来源:origin: io.brooklyn/brooklyn-software-nosql

@Override
public void customize() {
  Map ports = ImmutableMap.of("port", getServerPort());
  Networking.checkPortsValid(ports);
  String command = String.format("mkdir -p %s", getDataDirectory());
  newScript(CUSTOMIZING)
      .updateTaskAndFailOnNonZeroResultCode()
      .body.append(command).execute();
  String templateUrl = entity.getConfig(MongoDBServer.MONGODB_CONF_TEMPLATE_URL);
  if (!Strings.isNullOrEmpty(templateUrl)) copyTemplate(templateUrl, getConfFile());
}

代码示例来源:origin: io.brooklyn/brooklyn-software-nosql

@Override
public void customize() {
  log.info("Customizing {} (Cluster {})", entity, getClusterName());
  Networking.checkPortsValid(getPortMap());
  newScript(CUSTOMIZING).execute();
  // Copy the configuration files across
  String configFileContents = processTemplate(getCouchDBConfigTemplateUrl());
  String destinationConfigFile = String.format("%s/%s", getRunDir(), getCouchDBConfigFileName());
  getMachine().copyTo(new ByteArrayInputStream(configFileContents.getBytes()), destinationConfigFile);
  String uriFileContents = processTemplate(getCouchDBUriTemplateUrl());
  String destinationUriFile = String.format("%s/couch.uri", getRunDir());
  getMachine().copyTo(new ByteArrayInputStream(uriFileContents.getBytes()), destinationUriFile);
}

代码示例来源:origin: io.brooklyn/brooklyn-software-messaging

@Override
public void customize() {
  Networking.checkPortsValid(MutableMap.of("amqpPort", getAmqpPort()));
  newScript(CUSTOMIZING)
      .body.append(
        format("cp -R %s/* .", getExpandedInstallDir())
      )
      .execute();
}

代码示例来源:origin: io.brooklyn/brooklyn-software-webapp

ports.put("jmxPort",getJmxPort());
Networking.checkPortsValid(ports);

代码示例来源:origin: io.brooklyn/brooklyn-software-messaging

@Override
public void customize() {
  Networking.checkPortsValid(ImmutableMap.of("jmxPort", getJmxPort(), "openWirePort", getOpenWirePort()));
  newScript(CUSTOMIZING).
      body.append(
      String.format("cp -R %s/{bin,conf,data,lib,webapps} .", getExpandedInstallDir()),
      
      // Required in version 5.5.1 (at least), but not in version 5.7.0
      "sed -i.bk 's/\\[-z \"$JAVA_HOME\"]/\\[ -z \"$JAVA_HOME\" ]/g' bin/activemq",
      // Stop it writing to dev null on start
      "sed -i.bk \"s/\\(ACTIVEMQ_HOME..bin.run.jar.*\\)>.dev.null/\\1/\" bin/activemq",
      
      // Required if launching multiple AMQ's, prevent jetty port conflicts
      "sed -i.bk 's/8161/"+getEntity().getAttribute(ActiveMQBroker.AMQ_JETTY_PORT)+"/g' conf/jetty.xml"
      
      ).execute();
  
  // TODO disable persistence (this should be a flag -- but it seems to have no effect, despite ):
  // "sed -i.bk 's/broker /broker persistent=\"false\" /g' conf/activemq.xml",
  // Copy the configuration file across
  String configFileContents = processTemplate(getTemplateConfigurationUrl());
  String destinationConfigFile = format("%s/conf/activemq.xml", getRunDir());
  getMachine().copyTo(new ByteArrayInputStream(configFileContents.getBytes()), destinationConfigFile);
}

代码示例来源:origin: io.brooklyn/brooklyn-software-webapp

@Override
public void launch() {
  Map ports = MutableMap.of("httpPort",getHttpPort(), "jmxPort",getJmxPort());
  Networking.checkPortsValid(ports);
  
  Map flags = MutableMap.of("usePidFile",false);
  newScript(flags, LAUNCHING).
  body.append(
      "echo JAVA_OPTS is $JAVA_OPTS",
      format("./bin/jetty.sh " +
          "start etc/jetty.xml etc/jetty-logging.xml etc/jetty-jmx.xml etc/jetty-stats.xml "+
          ">>$RUN_DIR/console 2>&1 </dev/null"),
      "for i in {1..10}\n" +
      "do\n" +
      "    if [ -s "+getLogFileLocation()+" ]; then exit; fi\n" +
      "    sleep 1\n" +
      "done\n" +
    "echo \"Couldn't determine if jetty-server is running (log file is still empty); continuing but may subsequently fail\""
  ).execute();
  log.debug("launched jetty");
}

代码示例来源:origin: io.brooklyn/brooklyn-software-nosql

@Override
public void customize() {
  log.debug("Customizing {} (Cluster {})", entity, getClusterName());
  Networking.checkPortsValid(getPortMap());

代码示例来源:origin: io.brooklyn/brooklyn-software-messaging

@Override
public void customize() {
  Networking.checkPortsValid(getPortMap());
  newScript(CUSTOMIZING)
      .failOnNonZeroResultCode()
      .body.append(format("cp -R %s/* %s", getExpandedInstallDir(), getRunDir()))
      .execute();
  String config = entity.getConfig(getConfigTemplateKey());
  copyTemplate(config, getConfigFileName());
}

代码示例来源:origin: io.brooklyn/brooklyn-software-webapp

@Override
public void launch() {
  Map ports = MutableMap.of("httpPort", getHttpPort(), "shutdownPort", getShutdownPort());
  Networking.checkPortsValid(ports);
  Map flags = MutableMap.of("usePidFile",false);
  // We wait for evidence of tomcat running because, using 
  // brooklyn.ssh.config.tool.class=brooklyn.util.internal.ssh.cli.SshCliTool,
  // we saw the ssh session return before the tomcat process was fully running 
  // so the process failed to start.
  newScript(flags, LAUNCHING)
      .body.append(
          format("%s/bin/startup.sh >>$RUN/console 2>&1 </dev/null",getExpandedInstallDir()),
          "for i in {1..10}\n" +
          "do\n" +
          "    if [ -s "+getLogFileLocation()+" ]; then exit; fi\n" +
          "    sleep 1\n" +
          "done\n" +
          "echo \"Couldn't determine if tomcat-server is running (logs/catalina.out is still empty); continuing but may subsequently fail\"")
      .execute();
}

代码示例来源:origin: io.brooklyn/brooklyn-software-messaging

@Override
public void customize() {
  Networking.checkPortsValid(MutableMap.of("jmxPort", getJmxPort(), "amqpPort", getAmqpPort()));
  newScript(CUSTOMIZING)
      .body.append(
        format("cp -R %s/{bin,etc,lib} .", getExpandedInstallDir()),
        "mkdir lib/opt"
      )
      .execute();
  Map runtimeFiles = entity.getConfig(QpidBroker.RUNTIME_FILES);
  copyResources(runtimeFiles);
  Map runtimeTemplates = entity.getConfig(QpidBroker.RUNTIME_TEMPLATES);
  copyTemplates(runtimeTemplates);
}

代码示例来源:origin: io.brooklyn/brooklyn-software-webapp

@Override
public void launch() {
  // TODO if can't be root, and ports > 1024 are in the allowed port range,
  // prefer that; could do this on SshMachineLocation which implements PortSupplier,
  // invoked from PortAttrSensorAndConfigKey, which is invoked from MachineLifecycleTasks.preStartCustom
  Networking.checkPortsValid(MutableMap.of("httpPort", getHttpPort()));
  
  // By default, nginx writes the pid of the master process to "logs/nginx.pid"
  Map<Object,Object> flags = MutableMap.<Object,Object>of("usePidFile", false);
  
  // We wait for evidence of running because, using 
  // brooklyn.ssh.config.tool.class=brooklyn.util.internal.ssh.cli.SshCliTool,
  // we saw the ssh session return before the tomcat process was fully running 
  // so the process failed to start.
  newScript(flags, LAUNCHING).
      body.append(
      format("cd %s", getRunDir()),
      BashCommands.requireExecutable("./sbin/nginx"),
      sudoBashCIfPrivilegedPort(getHttpPort(), format(
          "nohup ./sbin/nginx -p %s/ -c conf/server.conf > ./console 2>&1 &", getRunDir())),
      format("for i in {1..10}\n" +
          "do\n" +
          "    test -f %s && ps -p `cat %s` && exit\n" +
          "    sleep 1\n" +
          "done\n" +
          "echo \"No explicit error launching nginx but couldn't find process by pid; continuing but may subsequently fail\"\n" +
          "cat ./console | tee /dev/stderr",
          getRunDir()+"/"+NGINX_PID_FILE, getRunDir()+"/"+NGINX_PID_FILE)
  ).execute();
}

代码示例来源:origin: io.brooklyn/brooklyn-software-network

@Override
public void customize() {
  Integer dnsPort = getEntity().getDnsPort();
  Map<String, Object> ports = MutableMap.<String, Object>of("dnsPort", dnsPort);
  Networking.checkPortsValid(ports);
  newScript(CUSTOMIZING)
      .body.append(
          // TODO determine name of ethernet interface if not eth0?
          IptablesCommands.insertIptablesRule(Chain.INPUT, "eth0", Protocol.UDP, dnsPort, Policy.ACCEPT),
          IptablesCommands.insertIptablesRule(Chain.INPUT, "eth0", Protocol.TCP, dnsPort, Policy.ACCEPT),
          BashCommands.sudo("service iptables save"),
          BashCommands.sudo("service iptables restart")
      ).execute();
}

代码示例来源:origin: io.brooklyn/brooklyn-software-webapp

ports.put("httpsPort", getHttpsPort());
Networking.checkPortsValid(ports);

代码示例来源:origin: io.brooklyn/brooklyn-software-base

Networking.checkPortsValid(ImmutableMap.of("httpPort", httpPort));
  cmd += " --port "+httpPort;
} else if (getEntity().getEnabledHttpProtocols().isEmpty()) {

相关文章