Search in sources :

Example 1 with H2ONode

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

the class CloudHandler method status.

// called through reflection by RequestServer
@SuppressWarnings("unused")
public CloudV3 status(int version, CloudV3 cloud) {
    // TODO: this really ought to be in the water package
    cloud.version = H2O.ABV.projectVersion();
    cloud.branch_name = H2O.ABV.branchName();
    cloud.build_number = H2O.ABV.buildNumber();
    cloud.build_age = PrettyPrint.toAge(H2O.ABV.compiledOnDate(), new Date());
    cloud.build_too_old = H2O.ABV.isTooOld();
    cloud.node_idx = H2O.SELF.index();
    cloud.cloud_name = H2O.ARGS.name;
    cloud.is_client = H2O.ARGS.client;
    cloud.cloud_size = H2O.CLOUD.size();
    cloud.cloud_uptime_millis = System.currentTimeMillis() - H2O.START_TIME_MILLIS.get();
    cloud.consensus = Paxos._commonKnowledge;
    cloud.locked = Paxos._cloudLocked;
    cloud.internal_security_enabled = H2OSecurityManager.instance().securityEnabled;
    // Fetch and calculate cloud metrics from individual node metrics.
    H2ONode[] members = H2O.CLOUD.members();
    cloud.bad_nodes = 0;
    cloud.cloud_healthy = true;
    if (null != members) {
        cloud.nodes = new CloudV3.NodeV3[members.length];
        for (int i = 0; i < members.length; i++) {
            cloud.nodes[i] = new CloudV3.NodeV3(members[i], cloud.skip_ticks);
            if (!cloud.nodes[i].healthy) {
                cloud.cloud_healthy = false;
                cloud.bad_nodes++;
            }
        }
    }
    return cloud;
}
Also used : H2ONode(water.H2ONode) CloudV3(water.api.schemas3.CloudV3) Date(java.util.Date) PrettyPrint(water.util.PrettyPrint)

Example 2 with H2ONode

use of water.H2ONode in project h2o-2 by h2oai.

the class GarbageCollect method serve.

@Override
public RequestBuilders.Response serve() {
    for (H2ONode node : H2O.CLOUD._memary) {
        GCTask t = new GCTask();
        new RPC<GCTask>(node, t).call().get();
    }
    return RequestBuilders.Response.doneEmpty();
}
Also used : RPC(water.RPC) H2ONode(water.H2ONode)

Example 3 with H2ONode

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

the class GAUtils method logStartup.

public static void logStartup() {
    if (H2O.GA != null) {
        if (H2O.SELF == H2O.CLOUD._memary[0]) {
            int cloudSize = H2O.CLOUD.size();
            H2O.GA.postAsync(new EventHit("System startup info", "Cloud", "Cloud size", cloudSize));
            if (cloudSize > 1)
                H2O.GA.postAsync(new EventHit("System startup info", "Cloud", "Multi-node cloud size", cloudSize));
            postRange("System startup info", "Cloud", "Cloud size", new int[] { 2, 3, 4, 5, 10, 20, 30, 40, 50, 60 }, cloudSize);
            if (H2O.ARGS.ga_hadoop_ver != null) {
                H2O.GA.postAsync(new EventHit("System startup info", "Hadoop version", H2O.ARGS.ga_hadoop_ver));
            } else if (H2O.CLOUD.size() > 1) {
                H2O.GA.postAsync(new EventHit("System startup info", "Hadoop version", "Non-hadoop cloud"));
            }
            // Figure out total memory usage
            int totMem = 0;
            for (H2ONode node : H2O.CLOUD.members()) // Sum at MB level
            totMem += node._heartbeat.get_free_mem() >> 20;
            //Simplfy to GB
            totMem = totMem >> 10;
            H2O.GA.postAsync(new EventHit("System startup info", "Memory", "Total Cloud Memory (GB)", totMem));
            postRange("System startup info", "Memory", "Total Cloud Memory (GB)", new int[] { 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 }, totMem);
        }
    }
}
Also used : EventHit(com.brsanthu.googleanalytics.EventHit) H2ONode(water.H2ONode)

Example 4 with H2ONode

use of water.H2ONode 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)

Example 5 with H2ONode

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

the class ClusterService method status.

@Override
public void status(Empty request, StreamObserver<ClusterInfo> responseObserver) {
    try {
        int numUnhealthy = 0;
        long now = System.currentTimeMillis();
        for (H2ONode node : H2O.CLOUD.members()) {
            if (!node.isHealthy(now))
                numUnhealthy++;
        }
        ClusterInfo cluster = ClusterInfo.newBuilder().setVersion(H2O.ABV.projectVersion()).setBranchName(H2O.ABV.branchName()).setBuildNumber(H2O.ABV.buildNumber()).setBuildAge(PrettyPrint.toAge(H2O.ABV.compiledOnDate(), new Date())).setName(H2O.ARGS.name).setNumNodes(H2O.CLOUD.size()).setUptimeMs(System.currentTimeMillis() - H2O.START_TIME_MILLIS.get()).setHasConsensus(Paxos._commonKnowledge).setIsLocked(Paxos._cloudLocked).setNumNodesUnhealthy(numUnhealthy).setClientMode(H2O.ARGS.client).build();
        responseObserver.onNext(cluster);
        responseObserver.onCompleted();
    } catch (Throwable ex) {
        GrpcUtils.sendError(ex, responseObserver, ClusterInfo.class);
    }
}
Also used : H2ONode(water.H2ONode) PrettyPrint(water.util.PrettyPrint) Date(java.util.Date)

Aggregations

H2ONode (water.H2ONode)6 PrettyPrint (water.util.PrettyPrint)3 Date (java.util.Date)2 EventHit (com.brsanthu.googleanalytics.EventHit)1 H2O (water.H2O)1 HeartBeat (water.HeartBeat)1 RPC (water.RPC)1 CloudV3 (water.api.schemas3.CloudV3)1