Search in sources :

Example 1 with H2O

use of water.H2O in project h2o-3 by h2oai.

the class AboutHandler method get.

// called through reflection by RequestServer
@SuppressWarnings("unused")
public AboutV3 get(int version, AboutV3 s) {
    ArrayList<AboutEntryV3> entries = new ArrayList<>();
    entries.add(new AboutEntryV3("Build git branch", H2O.ABV.branchName()));
    entries.add(new AboutEntryV3("Build git hash", H2O.ABV.lastCommitHash()));
    entries.add(new AboutEntryV3("Build git describe", H2O.ABV.describe()));
    entries.add(new AboutEntryV3("Build project version", H2O.ABV.projectVersion()));
    entries.add(new AboutEntryV3("Build age", PrettyPrint.toAge(H2O.ABV.compiledOnDate(), new Date())));
    entries.add(new AboutEntryV3("Built by", H2O.ABV.compiledBy()));
    entries.add(new AboutEntryV3("Built on", H2O.ABV.compiledOn()));
    entries.add(new AboutEntryV3("Internal Security", H2OSecurityManager.instance().securityEnabled ? "Enabled" : "Disabled"));
    if (H2O.ABV.isTooOld()) {
        String latestH2OVersion = H2O.ABV.getLatestH2OVersion();
        entries.add(new AboutEntryV3("Version warning", "Your H2O version is too old! Please download the latest version " + latestH2OVersion + " from http://h2o.ai/download/"));
    }
    for (H2O.AboutEntry ae : H2O.getAboutEntries()) {
        entries.add(new AboutEntryV3(ae.getName(), ae.getValue()));
    }
    s.entries = entries.toArray(new AboutEntryV3[entries.size()]);
    return s;
}
Also used : H2O(water.H2O) ArrayList(java.util.ArrayList) AboutEntryV3(water.api.schemas3.AboutEntryV3) Date(java.util.Date)

Example 2 with H2O

use of water.H2O in project h2o-3 by h2oai.

the class NetworkInit method multicast2.

private static void multicast2(ByteBuffer bb, byte priority) {
    if (!H2O.isFlatfileEnabled()) {
        byte[] buf = new byte[bb.remaining()];
        bb.get(buf);
        synchronized (H2O.class) {
            // Sync'd so single-thread socket create/destroy
            assert H2O.CLOUD_MULTICAST_IF != null;
            try {
                if (H2O.CLOUD_MULTICAST_SOCKET == null) {
                    H2O.CLOUD_MULTICAST_SOCKET = new MulticastSocket();
                    // Allow multicast traffic to go across subnets
                    H2O.CLOUD_MULTICAST_SOCKET.setTimeToLive(2);
                    H2O.CLOUD_MULTICAST_SOCKET.setNetworkInterface(H2O.CLOUD_MULTICAST_IF);
                }
                // Make and send a packet from the buffer
                H2O.CLOUD_MULTICAST_SOCKET.send(new DatagramPacket(buf, buf.length, H2O.CLOUD_MULTICAST_GROUP, H2O.CLOUD_MULTICAST_PORT));
            } catch (Exception e) {
                // awake from sleep.
                if (H2O.CLOUD_MULTICAST_SOCKET != null)
                    try {
                        H2O.CLOUD_MULTICAST_SOCKET.close();
                    } catch (Exception e2) {
                        Log.err("Got", e2);
                    } finally {
                        H2O.CLOUD_MULTICAST_SOCKET = null;
                    }
            }
        }
    } else {
        // Multicast Simulation
        // The multicast simulation is little bit tricky. To achieve union of all
        // specified nodes' flatfiles (via option -flatfile), the simulated
        // multicast has to send packets not only to nodes listed in the node's
        // flatfile (H2O.STATIC_H2OS), but also to all cloud members (they do not
        // need to be specified in THIS node's flatfile but can be part of cloud
        // due to another node's flatfile).
        //
        // Furthermore, the packet have to be send also to Paxos proposed members
        // to achieve correct functionality of Paxos.  Typical situation is when
        // this node receives a Paxos heartbeat packet from a node which is not
        // listed in the node's flatfile -- it means that this node is listed in
        // another node's flatfile (and wants to create a cloud).  Hence, to
        // allow cloud creation, this node has to reply.
        //
        // Typical example is:
        //    node A: flatfile (B)
        //    node B: flatfile (C), i.e., A -> (B), B-> (C), C -> (A)
        //    node C: flatfile (A)
        //    Cloud configuration: (A, B, C)
        //
        // Hideous O(n) algorithm for broadcast - avoid the memory allocation in
        // this method (since it is heavily used)
        HashSet<H2ONode> nodes = H2O.getFlatfile();
        nodes.addAll(water.Paxos.PROPOSED.values());
        bb.mark();
        for (H2ONode h2o : nodes) {
            if (h2o._removed_from_cloud)
                continue;
            try {
                bb.reset();
                if (H2O.ARGS.useUDP) {
                    CLOUD_DGRAM.send(bb, h2o._key);
                } else {
                    h2o.sendMessage(bb, priority);
                }
            } catch (IOException e) {
                Log.warn("Multicast Error to " + h2o, e);
            }
        }
    }
}
Also used : H2O(water.H2O) H2ONode(water.H2ONode)

Aggregations

H2O (water.H2O)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 H2ONode (water.H2ONode)1 AboutEntryV3 (water.api.schemas3.AboutEntryV3)1