/** Connect to {@code host}:{@code port}. */ public OptionalOnlineOptions hostAndPort(String host, int port) { if (data.host != null) { throw new IllegalStateException("Host and port were already set"); } if (host == null || host.isEmpty()) { throw new IllegalArgumentException("Host must be set"); } if (port <= 0) { throw new IllegalArgumentException("Port must be set"); } data.host = host; data.port = port; return new OptionalOnlineOptions(data); }
private ManagementClient(String mgmtAddress, int mgmtPort) { OnlineManagementClient onlineClient = null; try { onlineClient = org.wildfly.extras.creaper.core.ManagementClient.online(OnlineOptions.domain() .forProfile("clustered") .build() .hostAndPort(mgmtAddress, mgmtPort) .auth(LOGIN, PASSWORD) .build() ); } catch (IOException ex) { throw new IllegalStateException("Error during connecting to server CLI.", ex); } ops = new Operations(onlineClient); }
/** * <p>Connect to {@code localhost} and use the default management port of the application server. * This is {@code 9999} by default (JBoss AS 7), and if the system property {@code creaper.wildfly} is defined, * it changes to 9990 or (if {@link OptionalOnlineOptions#ssl(SslOptions) ssl} is used) to 9993 (WildFly). * This makes it easy to run the same code against both AS7 and WildFly only by defining a single system * property.</p> * * <p>Alternatively, the {@link OptionalOnlineOptions#protocol(ManagementProtocol) protocol()} method * can be used, which takes precedence over the methods described above. When it is called, the default port * depends on chosen {@link ManagementProtocol}.</p> */ public OptionalOnlineOptions localDefault() { data.localDefault = true; return new OptionalOnlineOptions(data); }
public void reloadServer() throws IOException, TimeoutException, InterruptedException { Administration admin = new Administration(org.wildfly.extras.creaper.core.ManagementClient.online(OnlineOptions.domain() .forHost("master") .build() .hostAndPort(NODE0_ADDRESS, NODE0_PORT) .auth(LOGIN, PASSWORD) .build() )); admin.reload(); }
public static OnlineManagementClient clientInit() throws IOException { OnlineOptions onlineOptions = OnlineOptions .standalone() .hostAndPort(PortProviderUtil.getHost(), 9990) // 9990 is default port for EAP 7 .connectionTimeout(120000) .build(); return ManagementClient.online(onlineOptions); }