Package com.enioka.jqm.jpamodel

Examples of com.enioka.jqm.jpamodel.Node


        // New EM (after setting thread name)
        EntityManager em = Helpers.getNewEm();

        // Get configuration data
        Node node = em.find(Node.class, this.engine.getNode().getId());
        this.step = Long.parseLong(Helpers.getParameter("internalPollingPeriodMs", String.valueOf(this.step), em));
        this.alive = Long.parseLong(Helpers.getParameter("aliveSignalMs", String.valueOf(this.step), em));
        em.close();
        this.localThread = Thread.currentThread();

        // Launch main loop
        long sinceLatestPing = 0;
        while (true)
        {
            try
            {
                Thread.sleep(this.step);
            }
            catch (InterruptedException e)
            {
                run = false;
            }
            if (!run)
            {
                break;
            }

            // Get session
            em = Helpers.getNewEm();

            // Check if stop order
            node = em.find(Node.class, node.getId());
            if (node.isStop())
            {
                jqmlogger.info("Node has received a stop order from the database");
                jqmlogger.trace("At stop order time, there are " + this.engine.getCurrentlyRunningJobCount() + " jobs running in the node");
                this.run = false;
                this.engine.stop();
                em.close();
                break;
            }

            // I am alive signal
            sinceLatestPing += this.step;
            if (sinceLatestPing >= this.alive * 0.9)
            {
                em.getTransaction().begin();
                em.createQuery("UPDATE Node n SET n.lastSeenAlive = current_timestamp() WHERE n.id = :id").setParameter("id", node.getId())
                        .executeUpdate();
                em.getTransaction().commit();
                sinceLatestPing = 0;
            }

View Full Code Here


    static Node checkAndUpdateNodeConfiguration(String nodeName, EntityManager em)
    {
        em.getTransaction().begin();

        // Node
        Node n = null;
        try
        {
            n = em.createQuery("SELECT n FROM Node n WHERE n.name = :l", Node.class).setParameter("l", nodeName).getSingleResult();
        }
        catch (NoResultException e)
        {
            jqmlogger.info("Node " + nodeName + " does not exist in the configuration and will be created with default values");
            n = new Node();
            n.setDlRepo(System.getProperty("user.dir") + "/outputfiles/");
            n.setName(nodeName);
            n.setPort(0);
            n.setRepo(System.getProperty("user.dir") + "/jobs/");
            n.setRootLogLevel("INFO");
            em.persist(n);
        }

        // Default queue
        Queue q = null;
View Full Code Here

    // ------------------ NODE ---------------------------------

    public static Node createNode(String nodeName, Integer port, String dlRepo, String repo, EntityManager em)
    {
        Node n = new Node();
        EntityTransaction transac = em.getTransaction();
        transac.begin();

        n.setName(nodeName);
        n.setPort(port);
        n.setDlRepo(dlRepo);
        n.setRepo(repo);
        try
        {
            n.setDns(InetAddress.getLocalHost().getHostName());
        }
        catch (UnknownHostException e)
        {
            n.setDns("localhost");
        }
        em.persist(n);
        transac.commit();
        return n;
    }
View Full Code Here

TOP

Related Classes of com.enioka.jqm.jpamodel.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.