/*
 * Copyright 2015 the original author or authors.
 *
 * Licensed 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.
 */
package io.atomix.examples.server;

import io.atomix.AtomixServer;
import io.atomix.catalyst.transport.Address;
import io.atomix.catalyst.transport.NettyTransport;
import io.atomix.copycat.server.storage.Storage;

import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;

/**
 * Server example.
 *
 * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
 */
public class StandaloneServerExample {

  /**
   * Starts the server.
   */
  public static void main(String[] args) throws Exception {
    if (args.length < 2)
      throw new IllegalArgumentException("must supply a local port and at least one remote host:port tuple");

    int port = Integer.valueOf(args[0]);

    Address address = new Address(InetAddress.getLocalHost().getHostName(), port);

    List<Address> members = new ArrayList<>();
    for (int i = 1; i < args.length; i++) {
      String[] parts = args[i].split(":");
      members.add(new Address(parts[0], Integer.valueOf(parts[1])));
    }

    AtomixServer server = AtomixServer.builder(address, members)
        .withTransport(new NettyTransport())
        .withStorage(Storage.builder()
          .withDirectory(System.getProperty("user.dir") + "/logs/" + port)
          .withMaxEntriesPerSegment(16)
          .build())
        .build();

    server.open().join();

    while (server.isOpen()) {
      Thread.sleep(1000);
    }
  }

}

@@ -843,24 +843,51 @@
 netAddress;%0A
+import java.time.Duration;%0A
 import java.
@@ -1243,42 +1243,23 @@
 y a 
-local port and at least one remote
+path and set of
  hos
@@ -1270,16 +1270,17 @@
 rt tuple
+s
 %22);%0A%0A   
@@ -1284,46 +1284,103 @@
     
-int port = Integer.valueOf(args%5B0%5D
+// Parse the address to which to bind the server.%0A    String%5B%5D mainParts = args%5B1%5D.split(%22:%22
 );%0A
-%0A
     
@@ -1413,57 +1413,119 @@
 ess(
-InetAddress.getLocalHost().getHostName(), port);%0A
+mainParts%5B0%5D, Integer.valueOf(mainParts%5B1%5D));%0A%0A    // Build a list of all member addresses to which to connect.
 %0A   
@@ -1909,56 +1909,187 @@
 ory(
-System.getProperty(%22user.dir%22) + %22/logs/%22 + port
+args%5B0%5D)%0A          .withMinorCompactionInterval(Duration.ofSeconds(30))%0A          .withMajorCompactionInterval(Duration.ofMinutes(1))%0A          .withMaxSegmentSize(1024 * 1024 * 8
 )%0A  
@@ -2127,9 +2127,18 @@
 nt(1
-6
+024 * 1024
 )%0A  

Update standalone server example to specify log directory and join an existing cluster.