Package org.wso2.carbon.bam.core.persistence

Examples of org.wso2.carbon.bam.core.persistence.BAMPersistenceManager


        } else {
            running = true;
        }

        List<ServerDO> serverList = null;
        BAMPersistenceManager persistenceManager;
        BAMDataServiceAdmin statisticsAdmin = new BAMDataServiceAdmin();

        try {
             persistenceManager = BAMPersistenceManager.getPersistenceManager(BAMUtil.getRegistry());
            if (persistenceManager != null) {
                serverList = Arrays.asList(persistenceManager.getMonitoredServersByType(BAMConstants.SERVER_TYPE_PULL));
            } else {
                throw new BAMException("Can't initialize BAMPersistenceManager");
            }
        } catch (Exception e) {
            if (log.isErrorEnabled()) {
                log.error("Error occurred while retrieving the server list for polling data", e);
            }
            return;
        }

        if (serverList != null && serverList.size() > 0) {
            BackOffCounter backoffcounter = BackOffCounter.getInstance();
            for (ServerDO server : serverList) {

                boolean isServerUp = isServerUpAndRunning(server);

                try {
                      Boolean state = false;
                    if(server.getActive()){
                        state =true;
                    }

                    if (state && !(backoffcounter.shouldBackoff(server))&& isServerUp) {

                        DataPuller  svrDataPuller = DataPullerFactory.getDataPuller(server, DataPullerFactory.SERVER_STATISTICS_PULLER);
                        MonitoredServerServiceInfoAdmin serviceInfoAdmin = new MonitoredServerServiceInfoAdmin();
                        String[] serviceNames = serviceInfoAdmin.getServiceNames(server);
                        ServerStatisticsDO svrStatisticsDO = (ServerStatisticsDO) svrDataPuller.pullData(server);
                        statisticsAdmin.addServerStatistics(svrStatisticsDO);

                        if (serviceNames != null && serviceNames.length > 0) {

                            DataPuller dataPuller = DataPullerFactory.getDataPuller(server,DataPullerFactory.SERVICE_STATISTICS_PULLER);
                            for (String serviceName : serviceNames) {
                                ServiceStatisticsDO svcStatisticsDO = (ServiceStatisticsDO) dataPuller.pullData(serviceName);
                                if (svcStatisticsDO != null) {
                                    statisticsAdmin.addServiceStatistics(svcStatisticsDO);
                                }

                                ServiceDO svc = persistenceManager.getService(server.getId(), serviceName);
                                String[] operationNames = serviceInfoAdmin.getOperationNames(server, serviceName);

                                if (operationNames != null && operationNames.length > 0) {
                                    DataPuller opDataPuller = DataPullerFactory.getDataPuller(server,
                                            DataPullerFactory.OPERTION_STATISTICS_PULLER);
View Full Code Here


    }
    }

    public void addServiceStatistics(ServiceStatisticsDO statisticsDO) throws BAMException {
        // Add the service if it doesn't exist
        BAMPersistenceManager pm = BAMPersistenceManager.getPersistenceManager(BAMUtil.getRegistry());
        int serviceId = statisticsDO.getServiceID();
        ServiceDO serviceDO;
        if (serviceId > 0) {
            serviceDO = pm.getService(serviceId);

        } else {
            serviceDO = pm.getService(statisticsDO.getServerID(), statisticsDO.getServiceName());
            statisticsDO.setServiceID(serviceDO.getId());
        }

        BAMDataCollectionDSClient client = null;
      try {
View Full Code Here

      }
    }
    }

    public void addOperationStatistics(OperationStatisticsDO statisticsDO) throws BAMException {
        BAMPersistenceManager pm = BAMPersistenceManager.getPersistenceManager(BAMUtil.getRegistry());
        int operationId = statisticsDO.getOperationID();
        OperationDO operationDO;
        ServiceDO service;

        int serviceID = statisticsDO.getServiceID();
        if (serviceID > 0) {
            service = pm.getService(serviceID);
        } else {
            service = pm.getService(statisticsDO.getServerID(), statisticsDO.getServiceName());
            statisticsDO.setServiceID(service.getId());
        }

        if (operationId > 0) {
            operationDO = pm.getOperation(operationId);
        } else {
            operationDO = pm.getOperation(statisticsDO.getServiceID() ,statisticsDO.getOperationName());
            statisticsDO.setOperationID(operationDO.getOperationID());
        }

        BAMDataCollectionDSClient client = null;
      try {
View Full Code Here

    public ServiceStatisticsDataPuller(ServerDO server) {
        setServer(server);
    }

    public StatisticsDO pullData(Object ctx) throws BAMException, RemoteException {
        BAMPersistenceManager pm = BAMPersistenceManager.getPersistenceManager(BAMUtil.getRegistry());
        String svcName = (String) ctx;
        String sessionCookie = ClientAuthHandler.getClientAuthHandler().getSessionString(getServer());
        StatisticsAdminClient client = new StatisticsAdminClient(getServer().getServerURL(), sessionCookie);
        ServiceStatistics svcStatistics = client.getServiceStatistics(svcName);
        ServiceStatisticsDO statisticsDO = new ServiceStatisticsDO();
        statisticsDO.setServerID(getServer().getId());
        statisticsDO.setServerURL(getServer().getServerURL());
        statisticsDO.setServiceName(svcName);

        //This should set svc.serviceID if the service is already in DB
          ServiceDO svc ;
        int serviceId = statisticsDO.getServiceID();

        if (serviceId > 0) {
            svc = pm.getService(serviceId);
        } else {
            svc = pm.getService(statisticsDO.getServerID(), statisticsDO.getServiceName());
        }


        if (svc == null) {
            svc = new ServiceDO();
View Full Code Here

    }

    protected void activate(ComponentContext ctx) {
        try {
            bundleContext = ctx.getBundleContext();
            BAMPersistenceManager persistenceManager = BAMPersistenceManager.getPersistenceManager(null);
            bundleContext.registerService(BAMPersistenceManager.class.getName(), persistenceManager, null);

            setup();

            try {
View Full Code Here

        collectionTimer.schedule(collector, dataCollectionDelay, dataCollectionInterval);

        log.info("BAM Data Collector started...");

        generator = new SummaryGenerationTask(bundleContext);
        BAMPersistenceManager persistenceManager = BAMPersistenceManager.getPersistenceManager(BAMUtil.getRegistry());
        if (persistenceManager != null) {
            summaryTimer.schedule(generator, summaryGenDelay, summaryGenInterval);

            log.info("BAM Summary Generator started...");
        }
View Full Code Here

     * @return The end line number, or -1 if could not be determined
     */
    public int getEndLineNumber() {
      int ret=-1;
     
      ActivityInterface parent=getParent();
     
      if (parent != null) {
        int index=parent.getSubActivities().indexOf(this);
       
        if (index != -1) {
          if (index < (parent.getSubActivities().size()-1)) {
            ActivityInterface other=parent.getSubActivities().get(index+1);
           
            ret = other.getStartLineNumber()-1;
          } else {
            ret = parent.getEndLineNumber();
          }
        }
      }
View Full Code Here

     *
     * @param lineNumber The line number
     * @return The activity, or null if not found
     */
    public ActivityInterface getActivityAtLineNumber(int lineNumber) {
      ActivityInterface ret=null;
     
      int endline=getEndLineNumber();
     
      if (getStartLineNumber() <= lineNumber && (endline == -1 || endline >= lineNumber)) {
       
View Full Code Here

            int width = 0;
            int height = 0;
            dimensions = new SVGDimension(width, height);

            SVGDimension subActivityDim = null;
            ActivityInterface activity = null;
            Iterator<org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface> itr = getSubActivities().iterator();
            while (itr.hasNext()) {
                activity = itr.next();
                subActivityDim = activity.getDimensions();
                if (subActivityDim.getWidth() > width) {
                    width += subActivityDim.getWidth();
                }
                height += subActivityDim.getHeight();
            }
View Full Code Here

    protected Element getArrows(SVGDocument doc) {
        Element subGroup = null;
        subGroup = doc.createElementNS("http://www.w3.org/2000/svg", "g");

        if (subActivities != null) {
            ActivityInterface prevActivity = null;
            ActivityInterface activity = null;
            String id = null;
            org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates exitCoords = null;
            SVGCoordinates entryCoords = null;
            Iterator<org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface> itr = subActivities.iterator();
            while (itr.hasNext()) {
                activity = itr.next();
                if (prevActivity != null) {
                    exitCoords = prevActivity.getExitArrowCoords();
                    entryCoords = activity.getEntryArrowCoords();
                    id = prevActivity.getId() + "-" + activity.getId();
                    subGroup.appendChild(getArrowDefinition(doc, exitCoords.getXLeft(),
                        exitCoords.getYTop(), entryCoords.getXLeft(),
                        entryCoords.getYTop(), id, prevActivity, activity));
                }
                prevActivity = activity;
View Full Code Here

TOP

Related Classes of org.wso2.carbon.bam.core.persistence.BAMPersistenceManager

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.