Examples of Persister


Examples of smilehouse.opensyncro.system.Persister

        //Go through each database listed in the properties file and, depending on the settings, start or remove
        //found pipe execution request.
        HashMap db=Environment.getInstance().getDatabaseInfo();
        Iterator it=db.keySet().iterator();
        while(it.hasNext()){
          Persister pers;
          String database=(String)it.next();
          try{
            pers=new Persister(database);
          }
          catch(DatabaseConnectionException dce){
            Environment.getInstance().log(dce.getMessage());
            continue;
          }
          String mode=(String)db.get(database);
          //Database listed, but no resumemode specified
         
          if(mode==null){
            Environment.getInstance().log("Mode not specified for database "+database);
          }
          //Delete all execution request from this database
          else if(mode.equalsIgnoreCase(CLEAR_MODE)){
            pers.deleteAllPipeExecutionRequests(null);
          }
          //Execute found execution requests
          else if(mode.equalsIgnoreCase(EXECUTE_MODE)){
            Iterator pipeIt=pers.loadAllPipes().iterator();
           
            //Iterate through all the pipes found in the database
            while (pipeIt.hasNext()) {
              Persister perPipePersister = new Persister(database);
          Pipe p = perPipePersister.findPipeByName(((Pipe) pipeIt.next()).getName());
          String dbase = perPipePersister.getDatabaseName();
          PipeWrapper pw = new PipeWrapper(p, dbase, dbase + p.getName());
          PipeExecutionThread pet = new PipeExecutionThread(pipesAndThreads,
              p.getId(),perPipePersister);
          //PipeExecutionQueue peq = new PipeExecutionQueue(perPipePersister,
            //  p.getId());
View Full Code Here

Examples of smilehouse.opensyncro.system.Persister

      
        // HashMap persisters contains a persister for each active pipe that is started via HttpStart.
       if(persisters == null)
      persisters = new HashMap();
       
        Persister pers=(Persister)persisters.get(database + pipeName);
        if(pers==null||pers.isClosed()){
          try {
        pers = new Persister(database);
        //unique pipe identification by database name and pipename
        persisters.put(database + pipeName, pers);
      } catch (DatabaseConnectionException e) {
        return("ERROR: Invalid database name");
      }
        }
       
    int queueLength = 0;
    try {
      PipeWrapper pipe = null;

      Map pipesAndThreads = null;

      // Get pipesAndThreads object from webapp context.
      // This is where running pipes and threads are listed
      pipesAndThreads = (Map) this.getServletContext().getAttribute(PIPES_AND_THREADS);
      boolean newThread = false;

      if (pipesAndThreads == null) {
        // No pipesAndThreads object exists -> no pipes have been started via HttpStart
        // nor has SyncroStartup started any.
        // Create synchronized map, as it may be modified simultaneously by several threads
        pipesAndThreads = Collections.synchronizedMap(new HashMap());
        this.getServletContext().setAttribute(PIPES_AND_THREADS,
            pipesAndThreads);
      }
     
      Iterator pipesIt=pipesAndThreads.keySet().iterator();
      boolean newPipe=true;
      // Iterate through active pipes to see if the pipe the incoming request refers to
      // is already executing

      while(pipesIt.hasNext()){
        PipeWrapper p = (PipeWrapper)pipesIt.next();
        String db=((PipeExecutionThread)pipesAndThreads.get(p)).getDatabaseName();
        //Since two databases could have pipes with the same name it is necessary to
        //check that in addition to pipe name database name also matches.
        if(p.getPipe().getName().equals(pipeName) && db.equals(database)){
          //Pipe was found. No need to create a new pipe
          newPipe=false;
          pipe=p;
        }
      }
      if(newPipe)
        pipe = new PipeWrapper(pers.findPipeByName(pipeName), database, database + pipeName);
     
      if(pipe == null || pipe.getPipe().getStartPassword() == null
          || !pipe.getPipe().getStartPassword().equals(startPassword)) {
        return "ERROR: Incorrect pipe name or start password";
      }
View Full Code Here

Examples of smilehouse.opensyncro.system.Persister

            setExecutionEndInfo( new Date(), System.currentTimeMillis()-start, statusCode);
            addLogEntry(logEntry, statusCode);
           
            // Add "--" log message entry when there are no other entries.
            // Needed to display log entries that don't have log message entries.
            Persister persister = new Persister(database);
            if (persister.getLogMessageEntries(logEntry.getId(), MessageLogger.LOG_DYNAMIC).size() == 0){
              logEntry.setIndex(1);
              logEntry.logMessage("--", MessageLogger.ERROR);
            }

        }
View Full Code Here

Examples of smilehouse.opensyncro.system.Persister

        // ever-increasing amount of server resources.

        //this.log.add(logEntry);
        String status = getStatusString(statusCode);
       
        Persister persister = new Persister(database);

        try {
            persister.update(logEntry);

            List messages;
           
            boolean mailAddressNotSet =((getMailHost() == null || getRecipientAddress() == null) ||
                    (getMailHost().length() == 0 || getRecipientAddress().length() == 0));
           
            // Notification via email only if host and email address are present
            if(!mailAddressNotSet&&!(getTransferLogNotificationLevel()==MessageLogger.MAIL_NONE)) {
               

                String date = dateFormat.format(new Date());
                String subject = this.getName() + " " + status + " " + date + " (" + database + ")";
                String message = "";

                // Get number of log messages at or below transferLogNotificationLevel. 
               
                int entries=persister.getLogMessageEntries(logEntry.getId(), getTransferLogNotificationLevel()).size();
               
                //Generate mail message
                if(entries > 0) {
                  
                  messages = persister.getLogMessageEntries(
                             logEntry.getId(),
                             getLoggingVerbosityLevel());
                    for(Iterator m = messages.iterator(); m.hasNext();) {
                        LogMessageEntry messageEntry = (LogMessageEntry) m.next();
                        message += (messageEntry.getMessage()) + "\n";
                    }
                } else {
                    message += MAIL_MESSAGE_NO_ENTRIES;
                }
               
                // Send notification email except when the message is
        // MAIL_MESSAGE_NO_ENTRIES or the pipe has aborted and
                // isAbortMailEnabled()==true
        if (!message.equals(MAIL_MESSAGE_NO_ENTRIES)
            || (statusCode==LogEntry.STATUS_ABORTED && isAbortMailEnabled())) {
          try {

            Properties props = new Properties();
            props.put("mail.host", getMailHost());

            Session mailConnection = Session.getInstance(props,
                null);
            Message msg = new MimeMessage(mailConnection);
            Address sender = new InternetAddress(MAIL_SENDER + "@"
                + getMailHost(), MAIL_SENDER);
            Address[] receivers = receiverAddresses(getRecipientAddress());

            // Set mail content and subject
            msg.setContent(message, "text/plain");
            msg.setFrom(sender);
            msg.setRecipients(Message.RecipientType.TO, receivers);
            msg.setSubject(subject);

            // Send the mail
            Transport.send(msg);

          } catch (MessagingException e) {
            String error = "An error occurred when sending mail report from "
                + MAIL_SENDER
                + "@"
                + getMailHost()
                + " to "
                + getRecipientAddress()
                + ":\n"
                + e.getMessage();
            Environment.getInstance().log(error);
            logEntry.logMessage(error, this, MessageLogger.ERROR);
            persister.update(logEntry);
          } catch (RuntimeException ex) {
            Environment.getInstance().log(
                "A RuntimeException has occurred: "
                    + ex.getMessage()
                    + ex.getStackTrace().toString());
          }
        }
      }
            // Remove unnecessary (debug level) messages from the LogEntry if Transfer log
            // verbosity level is set to DYNAMIC and the current LogEntry's status is either
            // OK or ABORTED
            if(getLoggingVerbosityLevel() == MessageLogger.LOG_DYNAMIC
                    && (statusCode == LogEntry.STATUS_OK || statusCode == LogEntry.STATUS_ABORTED) ) {
                messages = persister.getLogMessageEntries(logEntry.getId(), MessageLogger.DEBUG);
                if(messages.size() > 0) {
                    for(Iterator m = messages.iterator(); m.hasNext();) {
                        LogMessageEntry messageEntry = (LogMessageEntry) m.next();
                        if(messageEntry.getMessageType() == MessageLogger.DEBUG) {
                            persister.delete(messageEntry);
                           
                        }
                    }
                }
            }
        } catch(Exception e) {
            Environment.getInstance().log(e.getMessage());
        } finally {
            persister.close();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.