Example usage for java.util.concurrent ConcurrentHashMap keys

List of usage examples for java.util.concurrent ConcurrentHashMap keys

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentHashMap keys.

Prototype

public Enumeration<K> keys() 

Source Link

Document

Returns an enumeration of the keys in this table.

Usage

From source file:com.iitb.cse.Utils.java

public static Enumeration<String> getAllBssids() {

    ConcurrentHashMap<String, Boolean> obj = new ConcurrentHashMap<String, Boolean>();
    ConcurrentHashMap<String, DeviceInfo> clients = Constants.currentSession.getConnectedClients();
    Enumeration<String> macList = clients.keys();

    if (clients != null) {
        while (macList.hasMoreElements()) {
            String macAddr = macList.nextElement();
            DeviceInfo device = clients.get(macAddr);
            obj.put(device.getBssid(), Boolean.TRUE);
        }//from  w  ww  .  j a v  a  2 s. com
    }

    Enumeration<String> bssidList = obj.keys();
    return bssidList;
}

From source file:com.iitb.cse.Utils.java

public static Enumeration<String> getAllSsids() {

    ConcurrentHashMap<String, Boolean> obj = new ConcurrentHashMap<String, Boolean>();
    ConcurrentHashMap<String, DeviceInfo> clients = Constants.currentSession.getConnectedClients();
    Enumeration<String> macList = clients.keys();

    if (clients != null) {
        while (macList.hasMoreElements()) {
            String macAddr = macList.nextElement();
            DeviceInfo device = clients.get(macAddr);
            obj.put(device.getSsid(), Boolean.TRUE);
        }//from w ww .ja  v  a  2  s  . c om
    }

    Enumeration<String> bssidList = obj.keys();
    return bssidList;
}

From source file:com.iitb.cse.Utils.java

public static CopyOnWriteArrayList<DeviceInfo> activeClients() {
    //   (Utils.getCurrentTimeStamp().getTime() - device.getLastHeartBeatTime().getTime())/1000 > 60 
    //        int count = 0;

    ConcurrentHashMap<String, DeviceInfo> clients = Constants.currentSession.getConnectedClients();
    Enumeration<String> macList = clients.keys();
    ConcurrentHashMap<String, DeviceInfo> connectedClients = new ConcurrentHashMap<String, DeviceInfo>();
    CopyOnWriteArrayList<DeviceInfo> activeClients = new CopyOnWriteArrayList<DeviceInfo>();

    if (clients != null) {
        while (macList.hasMoreElements()) {
            String macAddr = macList.nextElement();
            DeviceInfo device = clients.get(macAddr);
            if ((Utils.getCurrentTimeStamp().getTime() - device.getLastHeartBeatTime().getTime())
                    / 1000 <= Constants.heartBeatAlive) {
                activeClients.add(device);
                //                   count++;
            }/*  ww w  .j a  va  2 s . c  o m*/
        }
    }
    return activeClients;
}

From source file:com.web.server.WarDeployer.java

public void removeServletFromSessionObject(WebAppConfig webAppConfig, String warDirectory) {
    Enumeration sessionKeys = sessionObjects.keys();
    while (sessionKeys.hasMoreElements()) {
        String sessionKey = (String) sessionKeys.nextElement();
        HttpSessionServer session = (HttpSessionServer) sessionObjects.get(sessionKey);
        ConcurrentHashMap servletMap = webAppConfig.getServlets();
        Enumeration servlets = servletMap.keys();
        while (servlets.hasMoreElements()) {
            String servletname = (String) servlets.nextElement();
            Servlets servletsMapping = (Servlets) servletMap.get(servletname);
            logger.info("SERVLETNAME:" + warDirectory + servletsMapping.getServletName()
                    + session.getAttribute("SERVLETNAME:" + warDirectory + servletsMapping.getServletName()));
            session.removeAttribute("SERVLETNAME:" + warDirectory + servletsMapping.getServletName());
        }/*  ww w  .j a va 2  s.c o  m*/
    }
}

From source file:com.app.server.WarDeployer.java

public void removeServletFromSessionObject(WebAppConfig webAppConfig, String warDirectory) {
    Enumeration sessionKeys = sessionObjects.keys();
    while (sessionKeys.hasMoreElements()) {
        String sessionKey = (String) sessionKeys.nextElement();
        HttpSessionServer session = (HttpSessionServer) sessionObjects.get(sessionKey);
        ConcurrentHashMap servletMap = webAppConfig.getServlets();
        Enumeration servlets = servletMap.keys();
        while (servlets.hasMoreElements()) {
            String servletname = (String) servlets.nextElement();
            Servlets servletsMapping = (Servlets) servletMap.get(servletname);
            /*log.info("SERVLETNAME:"
                  + warDirectory// w w w .  j av a  2s .com
                  + servletsMapping.getServletName()
                  + session.getAttribute("SERVLETNAME:" + warDirectory
                + servletsMapping.getServletName()));*/
            session.removeAttribute("SERVLETNAME:" + warDirectory + servletsMapping.getServletName());
        }
    }
}

From source file:hu.sztaki.lpds.pgportal.portlets.workflow.RealWorkflowPortlet.java

/**
 * Rescue a given workflow instance//from w  ww  . j  ava 2 s .co m
 */
public void doRescue(ActionRequest request, ActionResponse response) throws PortletException {
    if (WorkflowInfo(request, response)) {
        doDetails(request, response);
        //
        Vector errorJobPidList = new Vector();
        String portalID = PropertyLoader.getInstance().getProperty("service.url");
        String userID = request.getRemoteUser();
        String workflowID = request.getParameter("workflow");
        String runtimeID = request.getParameter("rtid");
        //
        String wfStatus = "" + PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                .getRuntime(runtimeID).getStatus();
        if (("7".equals(wfStatus)) || ("28".equals(wfStatus)) || ("23".equals(wfStatus))) {
            //
            // 23 = running/error
            if ("23".equals(wfStatus)) {
                // entering of running workflow status
                PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID).getRuntime(runtimeID)
                        .setStatus("5", 0);
            } else {
                // entering of resuming workflow status
                PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID).getRuntime(runtimeID)
                        .setStatus("29", 0);
            }
            //
            ConcurrentHashMap tmp = PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                    .getRuntime(runtimeID).getJobsStatus();
            Enumeration enm0 = tmp.keys();
            String ts;
            while (enm0.hasMoreElements()) {
                Object key0 = enm0.nextElement();
                Enumeration enm1 = ((ConcurrentHashMap) tmp.get(key0)).keys();
                while (enm1.hasMoreElements()) {
                    Object key1 = enm1.nextElement();
                    ts = "" + ((JobStatusData) ((ConcurrentHashMap) tmp.get(key0)).get(key1)).getStatus();
                    if (ts.equals("25") || ts.equals("22") || ts.equals("21") || ts.equals("7")
                            || ts.equals("15") || ts.equals("13") || ts.equals("12")) {
                        // entering init status
                        // PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID).getRuntime(runtimeID).addJobbStatus((String)key0,(String)key1,"1","",-1);
                        // clearing job from registry
                        PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                                .getRuntime(runtimeID).removeJobStatus((String) key0, (String) key1);
                        // collecting jobID/jobPID for storage cleanup 
                        ComDataBean comDataBean = new ComDataBean();
                        comDataBean.setJobID((String) key0);
                        comDataBean.setJobPID((String) key1);
                        errorJobPidList.addElement(comDataBean);
                    }
                }
            }
            if (UserQuotaUtils.getInstance().userQuotaIsFull(request.getRemoteUser())) {
                request.setAttribute("msg", "portal.RealWorkflowPortlet.quotaisoverfull");
            } else {
                new WorkflowRescueThread(portalID, userID, workflowID, runtimeID, wfStatus, errorJobPidList);
            }
        }
        // request.setAttribute("jsp",mainjsp;
        request.setAttribute("jsp", "/jsp/workflow/wrkinst.jsp");
    }
}

From source file:hu.sztaki.lpds.pgportal.portlets.workflow.RealWorkflowPortlet.java

private void doAbort(String userID, String workflowID, String runtimeID) {
    try {/*from www. ja  va2 s .c  om*/
        if (PortalCacheService.getInstance().getUser(userID) != null) {
            if (PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID) != null) {
                if (PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                        .getRuntime(runtimeID) != null) {
                    String wfStatus = "" + PortalCacheService.getInstance().getUser(userID)
                            .getWorkflow(workflowID).getRuntime(runtimeID).getStatus();
                    if (("5".equals(wfStatus)) || ("23".equals(wfStatus)) || ("2".equals(wfStatus))) {
                        // PortalCacheService.getInstance().getUser(userID).getWorkflow(request.getParameter("workflow")).getRuntime(request.getParameter("rtid")).setStatus("22", 0);
                        // suspending workflow status beallitasa...
                        PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                                .getRuntime(runtimeID).setStatus("28", 0);
                        ConcurrentHashMap tmp = PortalCacheService.getInstance().getUser(userID)
                                .getWorkflow(workflowID).getRuntime(runtimeID).getJobsStatus();
                        Enumeration enm0 = tmp.keys();
                        while (enm0.hasMoreElements()) {
                            Object key0 = enm0.nextElement();
                            Enumeration enm1 = ((ConcurrentHashMap) tmp.get(key0)).keys();
                            while (enm1.hasMoreElements()) {
                                Object key1 = enm1.nextElement();
                                // System.out.println("--"+key0+"/"+key1+"="+((JobStatusData)((Hashtable)tmp.get(key0)).get(key1)).getStatus());
                                String ts = "" + ((JobStatusData) ((ConcurrentHashMap) tmp.get(key0)).get(key1))
                                        .getStatus();
                                if (!(ts.equals("6") || ts.equals("7") || ts.equals("21") || ts.equals("1"))) {
                                    PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                                            .getRuntime(runtimeID)
                                            .addJobbStatus((String) key0, (String) key1, "22", "", -1);
                                }
                            }
                        }
                        new WorkflowAbortThread(userID, workflowID, runtimeID);
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:hu.sztaki.lpds.pgportal.portlets.workflow.EasyWorkflowPortlet.java

/**
 * Aborting all workflow instances/*from  w w  w .j  a  v  a  2 s .  c o m*/
 */
public void doAbortAll(ActionRequest request, ActionResponse response) throws PortletException {
    String userID = request.getRemoteUser();
    String workflowID = request.getParameter("workflow");

    ConcurrentHashMap tmph = PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
            .getAllRuntimeInstance();
    Enumeration enm = tmph.keys();
    String ts;
    while (enm.hasMoreElements()) {
        ts = "" + enm.nextElement();
        doAbort(userID, workflowID, ts);
    }
    doDetails(request, response);
}

From source file:hu.sztaki.lpds.pgportal.portlets.workflow.EasyWorkflowPortlet.java

/**
 * Data transmision to vizualize Portlet UI
 *//*from www . j a v  a 2s  .c o  m*/
@Override
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    response.setContentType("text/html");
    if (!isInited()) {
        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/error/init.jsp").include(request, response);
        return;
    }
    openRequestAttribute(request);
    // WSPgradeLogger.viewStart(request.getRemoteUser(), this.getClass().getName());
    try {
        //if("main".equals(request.getParameter("render"))) jsp=mainjsp;
        if (request.getAttribute("jsp") == null)
            request.setAttribute("jsp", mainjsp);

        if (request.getAttribute("jsp").equals(mainjsp)) {
            ConcurrentHashMap wfmainhsh = new ConcurrentHashMap();
            ConcurrentHashMap wfhsh = PortalCacheService.getInstance().getUser(request.getRemoteUser())
                    .getWorkflows();
            Enumeration keys = wfhsh.keys();
            while (keys.hasMoreElements()) {
                String wf = keys.nextElement().toString();
                WorkflowData wData = PortalCacheService.getInstance().getUser(request.getRemoteUser())
                        .getWorkflow(wf);
                if (wData.isAppMain()) {
                    //System.out.println("main found :" + wf);
                    wfmainhsh.put(wf, wfhsh.get(wf));
                }
            }

            request.setAttribute("appWorkflowList", Sorter.getInstance().sortFromValues(wfmainhsh));//wfmainhsh
        }
        request.setAttribute("userID", request.getRemoteUser());
        request.setAttribute("portalID", PropertyLoader.getInstance().getProperty("service.url"));
        PortletRequestDispatcher dispatcher = null;
        dispatcher = pContext.getRequestDispatcher((String) request.getAttribute("jsp"));
        dispatcher.include(request, response);
    } catch (IOException e) {
        throw new PortletException("JSPPortlet.doView exception", e);
    }
    cleanRequestAttribute(request.getPortletSession());
    //        action = "";
    //        WSPgradeLogger.viewStop(request.getRemoteUser(), this.getClass().getName());
}

From source file:hu.sztaki.lpds.pgportal.portlets.workflow.EasyWorkflowPortlet.java

private void doAbort(String userID, String workflowID, String runtimeID) {
    try {//from   w  ww  . j  a v a2s. c o m
        if (PortalCacheService.getInstance().getUser(userID) != null) {
            if (PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID) != null) {
                if (PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                        .getRuntime(runtimeID) != null) {
                    int wfStatus = PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                            .getRuntime(runtimeID).getStatus();
                    if ((5 == wfStatus) || (23 == wfStatus) || (2 == wfStatus)) {
                        // PortalCacheService.getInstance().getUser(userID).getWorkflow(request.getParameter("workflow")).getRuntime(request.getParameter("rtid")).setStatus("22", 0);
                        // set suspending workflow status ...
                        PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                                .getRuntime(runtimeID).setStatus("28", 0);
                        ConcurrentHashMap tmp = PortalCacheService.getInstance().getUser(userID)
                                .getWorkflow(workflowID).getRuntime(runtimeID).getJobsStatus();
                        Enumeration enm0 = tmp.keys();
                        while (enm0.hasMoreElements()) {
                            Object key0 = enm0.nextElement();
                            Enumeration enm1 = ((ConcurrentHashMap) tmp.get(key0)).keys();
                            while (enm1.hasMoreElements()) {
                                Object key1 = enm1.nextElement();
                                // System.out.println("--"+key0+"/"+key1+"="+((JobStatusData)((Hashtable)tmp.get(key0)).get(key1)).getStatus());
                                int ts = ((JobStatusData) ((ConcurrentHashMap) tmp.get(key0)).get(key1))
                                        .getStatus();
                                if (!(ts == 6) || ts == 7 || ts == 21 || ts == 1) {
                                    PortalCacheService.getInstance().getUser(userID).getWorkflow(workflowID)
                                            .getRuntime(runtimeID)
                                            .addJobbStatus((String) key0, (String) key1, "22", "", -1);
                                }
                            }
                        }
                        new WorkflowAbortThread(userID, workflowID, runtimeID);
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}