예제 #1
0
  /**
   * Test batched prepared statement concurrency. Batch prepares must not disappear between the
   * moment when they were created and when they are executed.
   */
  public void testConcurrentBatching() throws Exception {
    // Create a connection with a batch size of 1. This should cause prepares and actual batch
    // execution to become
    // interspersed (if correct synchronization is not in place) and greatly increase the chance of
    // prepares
    // being rolled back before getting executed.
    Properties props = new Properties();
    props.setProperty(Messages.get(net.sourceforge.jtds.jdbc.Driver.BATCHSIZE), "1");
    props.setProperty(
        Messages.get(net.sourceforge.jtds.jdbc.Driver.PREPARESQL),
        String.valueOf(TdsCore.TEMPORARY_STORED_PROCEDURES));
    Connection con = getConnection(props);

    try {
      Statement stmt = con.createStatement();
      stmt.execute(
          "create table #testConcurrentBatch (v1 int, v2 int, v3 int, v4 int, v5 int, v6 int)");
      stmt.close();

      Vector exceptions = new Vector();
      con.setAutoCommit(false);

      Thread t1 = new ConcurrentBatchingHelper(con, exceptions);
      Thread t2 = new ConcurrentBatchingHelper(con, exceptions);
      t1.start();
      t2.start();
      t1.join();
      t2.join();

      assertEquals(0, exceptions.size());
    } finally {
      con.close();
    }
  }
 public synchronized void scanLibrary() {
   if (scanner == null) {
     scanner = new Thread(this, "Library Scanner");
     scanner.start();
   } else if (scanner.isAlive()) {
     LOGGER.info("Scanner is already running !");
   } else {
     scanner = new Thread(this, "Library Scanner");
     scanner.start();
   }
 }
예제 #3
0
  /** Starts thread to update user state cache used by the Outlook plugin */
  public void startStateCacheUpdate(
      final Customer customer,
      final int transitionId,
      final CustomerState newState,
      final Latch dbLatch,
      ThreadMonitor threadMonitor) {
    Thread thd =
        new Thread(
            new Runnable() {
              public void run() {
                // TODO:  Use EEngine.
                updateStateCache(customer, transitionId, newState, dbLatch);
              }
            },
            "State cache update " + transitionId);
    thd.start();

    if (threadMonitor != null && CustomerState.ACTIVE.equals(newState)) {
      try {
        threadMonitor.addThread(thd);
      } catch (IllegalArgumentException iae) {
        LOGGER.warn("failed to add (null) thread to monitor?", iae);
      }
    }
  }
 public void scanLibrary() {
   if (isScanLibraryRunning()) {
     LOGGER.info(Messages.getString("NetworkTab.70"));
   } else {
     scanner = new Thread(this, "Library Scanner");
     scanner.start();
   }
 }
예제 #5
0
 public void imprimirPagosAbonosaNota(
     List<Pago> pagosaVentas, double montoAcumulado, double saldoAnterior) {
   com.boutique.impresiones.PrintTask obj =
       new com.boutique.impresiones.PrintTask(
           7, pagosaVentas, ventaSeleccionada, montoAcumulado, saldoAnterior); // Venta de contado
   Thread t = new Thread(obj);
   t.start();
 }
예제 #6
0
  public static void main(String[] args) throws Exception {

    SerialTest main = new SerialTest();
    main.initialize();
    Thread t =
        new Thread() {
          public void run() {
            // the following line will keep this app alive for 1000    seconds,
            // waiting for events to occur and responding to them    (printing incoming messages to
            // console).
            try {
              Thread.sleep(1000000);
            } catch (InterruptedException ie) {
            }
          }
        };
    t.start();
    System.out.println("Started");
  }
예제 #7
0
  public static void main(String[] args) throws SQLException, ClassNotFoundException {
    Map<String, String> dbInfo = new HashMap<String, String>();
    dbInfo.put("dbUserName", "rpi");
    dbInfo.put("dbPassword", "admin");
    dbInfo.put("dbName", "projets3p2");
    dbInfo.put("dbAddress", "192.168.0.107");

    Thread t = new Thread(new DBReadActions(dbInfo, 2, null));
    t.start();

    /*int a = DBUser.UserLogin(conn, "Antoine", "Bouchard");
    DBUser user = new DBUser(conn,a);
    System.out.println("Vous êtes bien chez "+user.getFirstName()+" "+user.getLastName()+
    		" qui habite au "+user.getAddress());
    DBHouse house = user.getHouse();
    System.out.print("Etat système d'alarme: ");
    System.out.println(house.getAlarmSystemStateString());
    //conn.test();

    System.out.println("Code d'Action retourne par la demande de fermeture de porte patio = "
    					+house.unlockDoor(conn, 3));
    house.unlockDoor(conn, 3);
    house.lockDoor(conn, 3);
    house.unlockDoor(conn, 3);
    house.lockDoor(conn, 3);
    ArrayList<DBAction> recentActionList = house.getRecentActions();

    System.out.println("Taille de la liste d'actions récentes = "+recentActionList.size());
    DBAction action;
    for(int i =0;i<3;i++)
    {
    	action= recentActionList.get(i);
    	if(action!=null)
    	{
    		System.out.println("Action: " +action.getAction()+" Date: "+action.getDate());
    	}
    }
    conn.close();
    System.out.println("Fin");*/
  }
예제 #8
0
 public void ClientIn() {
   hostin = hi.getText();
   portin = Integer.parseInt(pi.getText());
   listener = new Thread(this);
   listener.start();
 }
예제 #9
0
 public void start() {
   if (thread == null) {
     thread = new Thread(this);
     thread.start();
   }
 }
예제 #10
0
  ChatClient(String login, int id, int grpId) throws IOException {
    super(login); // call the super constructor to name the JFrame.
    loginName = login;
    userId = id;
    groupId = grpId;

    ta = new JTextArea(18, 50);
    tf = new JTextField(50);

    send = new JButton("Send");
    logout = new JButton("Log Out");
    refresh = new JButton("Refresh");

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            try {
              dout.writeUTF(loginName + " " + "LOGOUT");
              System.exit(1);
            } catch (IOException e1) {
              e1.printStackTrace();
            }
          }
        });

    tf.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
              try {
                if (tf.getText().length() > 0) {
                  dout.writeUTF(loginName + " DATA " + tf.getText().toString());
                  tf.setText("");
                }
              } catch (IOException e1) {
                e1.printStackTrace();
              }
            }
          }

          @Override
          public void keyReleased(KeyEvent e) {}
        });

    send.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              if (tf.getText().length() > 0) {
                dout.writeUTF(loginName + " DATA " + tf.getText().toString());
                tf.setText("");
              }
            } catch (IOException e1) {
              e1.printStackTrace();
            }
          }
        });

    logout.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              dout.writeUTF(loginName + " LOGOUT ");
              System.exit(1);
            } catch (IOException e1) {
              e1.printStackTrace();
            }
          }
        });

    refresh.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            DatabaseOperations.executeAvailability();
          }
        });

    socket = new Socket("localhost", SOCKETNUMBER);

    din = new DataInputStream(socket.getInputStream());
    dout = new DataOutputStream(socket.getOutputStream());

    dout.writeUTF(loginName);
    dout.writeUTF(loginName + " LOGIN");

    thread = new Thread(this);
    thread.start();
    setup();
  }
예제 #11
0
  // ----This function gets the raw json from raw_data collection----
  // ---------the function separate the tweets and inserts it to all_tweets collection and calling
  // all other data processing methods-----------
  // ----------------------------------------------------------------------------------------
  public void update_all_tweets(final double num_of_slots, final double max_time_frame_hours)
      throws MongoException, ParseException {
    log4j.info("starting update_all_tweets function");
    String res = new String();
    Integer countelements = 0;
    while (true) {
      // DBCursor cursor = this.collrd.find();
      while (this.collrd.count() < 1) { // no documents to process
        try {
          log4j.info("there is no raw data at the moment, going to sleep for 10 seconds");
          Thread.currentThread();
          Thread.sleep(1000 * 10);
          log4j.info("woke up, continues");
          // cursor = this.collrd.find();
        } catch (InterruptedException e) {
          log4j.error("InterruptedException caught, at update_all_tweets");
          log4j.error(e);
        }
      }
      DBCursor cursor = this.collrd.find(); // get all documents from raw_data collection
      try {
        while (cursor.hasNext()) {
          DBObject currdoc = cursor.next();
          log4j.info("getting a document from the raw data db");
          Object results = currdoc.get("results"); // result - json array of tweets
          try {
            res = results.toString();
          } catch (NullPointerException e) {
            res = "";
          }
          Object obj = JSONValue.parse(res);
          log4j.info("making an array from the jsons tweets");
          JSONArray array = (JSONArray) obj; // make an array of tweets
          // JSONParser parser = new JSONParser();
          try {
            if (res != "") { // if there are tweets
              @SuppressWarnings("rawtypes")
              Iterator iterArray = array.iterator();
              log4j.info("iterating over array tweets");
              try {
                while (iterArray.hasNext()) {
                  Object current = iterArray.next();
                  final DBObject dbObject =
                      (DBObject) JSON.parse(current.toString()); // parse all tweet data to json
                  countelements++;
                  // System.out.println("element number" + countelements.toString());
                  dbObject.put("max_id", currdoc.get("max_id")); // add max_id to tweet data
                  dbObject.put("query", currdoc.get("query")); // add query word to tweet data
                  dbObject.put(
                      "query_time", currdoc.get("query_time")); // add query time to tweet data
                  dbObject.put("query_time_string", currdoc.get("query_time_string"));
                  dbObject.put(
                      "text",
                      "@"
                          + dbObject.get("from_user").toString()
                          + ": "
                          + dbObject.get("text").toString()); // add user_name to beginning of text
                  dbObject.put("count", 1L); // add appearance counter to tweet data
                  log4j.info("inserting tweet id: " + dbObject.get("id").toString());
                  try {
                    DBObject object = new BasicDBObject();
                    object.put(
                        "id", Long.parseLong(dbObject.get("id").toString())); // object to search
                    DBObject newobject = collat.findOne(object);
                    if (newobject != null) {
                      newobject.put(
                          "count",
                          Long.parseLong(newobject.get("count").toString())
                              + 1); // update counter if id already exists
                      collat.update(object, newobject);
                    }
                  } catch (NullPointerException e) {

                  }
                  collat.insert(dbObject);
                  // collrd.findAndRemove(currdoc);
                  // log4j.info("calling function update_search_terms");
                  // final String text = "@" + dbObject.get("from_user").toString() + ": " +
                  // dbObject.get("text").toString();

                  /*Thread t10=new Thread(new Runnable(){
                  	public void run(){
                  		UpdateTweetCounterId(Long.parseLong(dbObject.get("id").toString()));
                  	}
                  });*/

                  Thread t11 =
                      new Thread(
                          new Runnable() {
                            public void run() {
                              update_search_terms(
                                  dbObject.get("text").toString(),
                                  num_of_slots,
                                  max_time_frame_hours,
                                  dbObject.get("query").toString());
                            }
                          });

                  Thread t12 =
                      new Thread(
                          new Runnable() {
                            public void run() {
                              rate_user(
                                  Long.parseLong(dbObject.get("from_user_id").toString()),
                                  dbObject.get("from_user").toString(),
                                  max_time_frame_hours);
                              // UpdateUserRate((long)num_of_slots,slot_time_millis,Long.parseLong(dbObject.get("from_user_id").toString()) , dbObject.get("from_user").toString() ,(long)0);
                            }
                          });

                  Thread t13 =
                      new Thread(
                          new Runnable() {
                            public void run() {
                              String quer = dbObject.get("query").toString();
                              quer = quer.replaceAll("%40", "@");
                              quer = quer.replaceAll("%23", "#");
                              long id =
                                  (long)
                                      (Double.parseDouble(dbObject.get("query_time").toString())
                                          * 1000);
                              String idplus = dbObject.get("id").toString() + "," + id;
                              SearchResultId(quer, idplus);
                            }
                          });
                  // t10.start();
                  t11.start();
                  t12.start();
                  t13.start();
                  try {
                    log4j.info("Waiting for threads to finish.");
                    // t10.join();
                    t11.join();
                    t12.join();
                    t13.join();
                  } catch (InterruptedException e) {
                    log4j.error("Main thread (update_all_tweets) Interrupted");
                  }
                }
              } catch (Exception e) {
                log4j.error(e);
                e.printStackTrace();
              }
            }
          } catch (NullPointerException e) {
            log4j.error(e);
            log4j.info("NullPointerException caught, at update_all_tweets");
          }
          log4j.info("removing processed document from raw_data collection");
          try {
            this.collrd.remove(currdoc);
          } catch (Exception e) {
            log4j.debug(e);
          }
        }
      } catch (MongoException e) {
        log4j.error(e);
      }
    }
  }
  private void executeParsedFile(NameListMessage nameListMessage, ArrayList cmds) {
    BufferedWriter buffer = null;
    int connectionId = nameListMessage.connectionId;
    boolean commaSeparated = nameListMessage.commaSeparated;

    // get java.sql.Connection from connectionId
    Connection connection = ConnectionService.getConnection(connectionId);

    if (connection == null) {
      nameListMessage.errorMessage = kConnectionClosed;
    } else {

      try {
        Thread th = null;
        buffer = new BufferedWriter(writer);

        // if reader exists, create reading thread
        if (reader != null) {
          final ObjectNameReader objectReader = new ObjectNameReader(nameListMessage.nameList);

          // This thread will read stream until meets EOL (ie. when
          // writer is closed)
          th =
              new Thread() {
                public void run() {
                  objectReader.readInputFile(reader);
                }
              };
        } // end if

        // if no reader (offline reverse), never start the reading
        // thread
        // (because output is written down directly to the disk without
        // processing in counterpart).
        if (reader != null) th.start();

        // execute each SQL statement
        // we skip objects that don't need to be reversed
        Iterator iter = cmds.iterator();
        int index = -1;
        while (iter.hasNext()) {
          String cmd = (String) iter.next();
          index++;
          // check if this statement id is marked as <to skip>
          if (nameListMessage.ignoredStatementIds != null
              && nameListMessage.ignoredStatementIds.contains(new Integer(index))) {
            if (commaSeparated) {
              buffer.flush();
              buffer.newLine();
            }
            continue;
          }
          if (writer != null) {
            if (cmd != null) {
              try {
                execute(connection, cmd, buffer, commaSeparated);
              } catch (SQLException e) {
                if (Debug.isDebug()) e.printStackTrace();
                nameListMessage.errorMessage =
                    nameListMessage.errorMessage == null
                        ? e.toString()
                        : nameListMessage.errorMessage.concat("\n" + e.toString()); // NOT
                // LOCALIZABLE,
                // escape
                // code
              }
            }
            if (commaSeparated) {
              buffer.flush();
              buffer.newLine();
            }
          }
        }
      }
      /*
       * catch (SQLException ex) { if (Debug.isDebug()) ex.printStackTrace();
       * nameListMessage.errorMessage = nameListMessage.errorMessage == null ? ex.toString() :
       * nameListMessage.errorMessage.concat("\n" + ex.toString()); //NOT LOCALIZABLE, escape
       * code }
       */
      catch (IOException ex) {
        if (Debug.isDebug()) ex.printStackTrace();
        nameListMessage.errorMessage =
            nameListMessage.errorMessage == null
                ? ex.toString()
                : nameListMessage.errorMessage.concat(
                    "\n" + ex.toString()); // NOT LOCALIZABLE, escape
        // code
      }

      // close writer: the reading thread terminates.
      try {
        // WARNING: we must make a pause after closing the buffer
        // otherwise
        // the nameList variable won't be well initialized...strange!
        // [FG]
        buffer.close();
        Thread.sleep(400);
      } catch (IOException ex) {
      } catch (InterruptedException ex) {
      }
    } // end if
  } // end parseSqlFile()
예제 #13
0
파일: Dots.java 프로젝트: rcuvgd/tmlinux
  /**
   * Main function of the DOTS. Read the config file,create dotslogging,start performance client,
   * check db connection,create keyboard thread. Create new testcase according the cpu_usage and
   * connections, Write test summary and exception
   */
  public static void main(String[] args) {

    int sleepInterval = 1;
    int waitInterval = 0;
    int averageUsage = 0;
    boolean reached = false;
    Calendar currentTime;

    /* Load DotsConfig value */
    loadConfig(args);
    /* Create the instance of DotsLogging */
    DotsLogging logging = new DotsLogging(TESTCASENAME);

    DotsLogging.logMessage("Database Opensource Test Suite V1.0");
    DotsLogging.logMessage("Start to run JDBC API Test Case - " + TESTCASENAME);
    DotsLogging.logSummary("Start to run JDBC API Test Case - " + TESTCASENAME);
    if (!DotsConfig.RUN_AUTO) {
      System.out.println("\nDatabase Opensource Test Suite V1.0");
      System.out.println("\nStart to run JDBC API test case - " + TESTCASENAME);
    }

    DotsLogging.logMessage("Initialization started");
    if (!DotsConfig.RUN_AUTO) {
      System.out.println("\nTo stop running the test case, type STOP then press Enter\n");
    }
    /* Start performance monitor thread */
    startPerfCtl();

    /* Check database connection */
    checkDBConn();

    DotsLogging.logMessage("Testing Database Connections ...OK");

    /* Start summary writer thread */
    DotsSummary summary = new DotsSummary();
    summary.start();

    DotsLogging.logMessage("Starting Summary Writer ... OK ");

    /* Set begin and end time */
    Calendar endTime = Calendar.getInstance();
    DotsSummary.startTime = System.currentTimeMillis();
    endTime.add(Calendar.SECOND, DotsConfig.DURATION * 60);

    /* Start keyboard thread */
    if (!DotsConfig.RUN_AUTO) {
      startKeyboard();
      DotsLogging.logMessage("Starting Keyboard Thread ... OK");
    }

    boolean firstRun = true; // used for LOB manipulation
    String lobFileName[] = new String[10]; // used for LOB manipulation

    averageUsage = DotsConfig.CPU_USAGE;
    int targetCpu = DotsConfig.CPU_TARGET;
    try {
      while (true) {
        currentTime = Calendar.getInstance();
        if (currentTime.after(endTime)) break;
        if (DotsConfig.TERMINATION) break;
        /* Check if need create a new database access thread*/
        if ((DotsConfig.AUTO_MODE && (averageUsage < targetCpu))
            || (!DotsConfig.AUTO_MODE
                && (DotsConfig.THRDGRP.activeCount() < DotsConfig.CONNECTIONS))) {
          Connection conn =
              createConnection(
                  DotsConfig.DRIVER_CLASS_NAME,
                  DotsConfig.URL,
                  DotsConfig.DB_UID,
                  DotsConfig.DB_PASSWD);
          if (conn != null) {
            /* 5 second is a unit*/
            sleepInterval = DotsConfig.INTERVAL * 12;
            /* Create DB access thread */
            switch (TESTCASENAME.charAt(4)) {
              case '1':
                if (TESTCASENAME.equals("BTCJ1")) {
                  BTCJ1 btcj1 = new BTCJ1(conn);
                  Thread thrdb1 = new Thread(DotsConfig.THRDGRP, btcj1);
                  thrdb1.start();
                } else {
                  ATCJ1 atcj1 = new ATCJ1(conn);
                  Thread thrda1 = new Thread(DotsConfig.THRDGRP, atcj1);
                  thrda1.start();
                }
                break;
              case '2':
                if (TESTCASENAME.equals("BTCJ2")) {
                  BTCJ2 btcj2 = new BTCJ2(conn);
                  Thread thrdb2 = new Thread(DotsConfig.THRDGRP, btcj2);
                  thrdb2.start();
                } else {
                  ATCJ2 atcj2 = new ATCJ2(conn);
                  Thread thrda2 = new Thread(DotsConfig.THRDGRP, atcj2);
                  thrda2.start();
                }
                break;
              case '3':
                BTCJ3 btcj3 = new BTCJ3(conn);
                Thread thrdb3 = new Thread(DotsConfig.THRDGRP, btcj3);
                thrdb3.start();

                break;
              case '4':
                BTCJ4 btcj4 = new BTCJ4(conn);
                Thread thrdb4 = new Thread(DotsConfig.THRDGRP, btcj4);
                thrdb4.start();

                break;
              case '5':
                BTCJ5 btcj5 = new BTCJ5(conn);
                Thread thrdb5 = new Thread(DotsConfig.THRDGRP, btcj5);
                thrdb5.start();
                break;
              case '6':
                if (firstRun) {
                  for (int i = 0; i < 10; i++) {
                    lobFileName[i] = DotsGenerator.mdClob(DotsGenerator.mdInt(10, 100));
                  }
                  firstRun = false;
                }
                BTCJ6 btcj6 = new BTCJ6(conn, lobFileName);
                Thread thrdb6 = new Thread(DotsConfig.THRDGRP, btcj6);
                thrdb6.start();
                break;
              case '7':
                if (firstRun) {
                  for (int i = 0; i < 10; i++) {
                    lobFileName[i] = DotsGenerator.mdBlob(DotsGenerator.mdInt(10, 100));
                  }
                  firstRun = false;
                }
                BTCJ7 btcj7 = new BTCJ7(conn, lobFileName);
                Thread thrdb7 = new Thread(DotsConfig.THRDGRP, btcj7);
                thrdb7.start();
                break;
              case '8':
                BTCJ8 btcj8 = new BTCJ8(conn);
                Thread thrdb8 = new Thread(DotsConfig.THRDGRP, btcj8);
                thrdb8.start();
                break;
            }
          } else {
            /* If createConnection failed,sleepInterval will double,
            but the maximum of sleepInterval is 1 hour */
            sleepInterval = sleepInterval * 2;
            if (sleepInterval > 720) sleepInterval = 720;
          }
          try {
            averageUsage = 0;
            /* Wait 5*sleepInterval seconds,check TERMINATION per 5 second */
            for (int j = 0; j < sleepInterval; j++) {
              averageUsage += DotsConfig.CPU_USAGE;
              Thread.sleep(5000);
              if ((j % 12) == 0)
                DotsLogging.logMessage(
                    "Active Threads = "
                        + DotsConfig.THRDGRP.activeCount()
                        + " Average CPU Usage = "
                        + DotsConfig.CPU_USAGE
                        + "%");
              if (DotsConfig.TERMINATION) break;
              currentTime = Calendar.getInstance();
              if (currentTime.after(endTime)) {
                DotsConfig.TERMINATION = true;
                break;
              }
            }
            /* Calculate the average usage of this sleepInterval */
            averageUsage = averageUsage / sleepInterval;
            DotsLogging.logMessage(
                sleepInterval / 12 + " Minutes Average CPU Usage = " + averageUsage + "%");
          } catch (Exception e) {
            DotsLogging.logException("Dots.main: " + e);
          }

        } else {
          /* When CPU_TARGET is reached,DOTS will not create new thread until
          average usage is less than CPU_TARGET-10 */
          if (DotsConfig.AUTO_MODE && !reached) {
            reached = true;
            targetCpu = DotsConfig.CPU_TARGET - 10;
            DotsLogging.logMessage("CPU Target " + DotsConfig.CPU_TARGET + "% is achieved now.");
          }
          /* Wait 5 minutes then check create connection condition */
          try {
            averageUsage = 0;
            for (int i = 0; i < 60; i++) {
              averageUsage += DotsConfig.CPU_USAGE;
              Thread.sleep(5000);
              if ((i % 12) == 0)
                DotsLogging.logMessage(
                    "Active Threads = "
                        + DotsConfig.THRDGRP.activeCount()
                        + " Average CPU Usage = "
                        + DotsConfig.CPU_USAGE
                        + "%");
              if (DotsConfig.TERMINATION) break;
              currentTime = Calendar.getInstance();
              if (currentTime.after(endTime)) {
                DotsConfig.TERMINATION = true;
                break;
              }
            }
            averageUsage = averageUsage / 60;
            DotsLogging.logMessage("5 Minutes Average CPU Usage = " + averageUsage + "%");
          } catch (Exception e) {
            DotsLogging.logException("Dots.main: " + e);
          }
        }
      }
    } catch (Throwable t) {
      DotsLogging.logException("Dots.main: " + t);
      System.out.println("Dots.main:" + t);
    }

    /* DURATION is reached or TERMINATION is set by other threads */
    DotsConfig.TERMINATION = true;
    DotsLogging.logMessage("Dots is Terminating ...");
    /* Clear temporary file used by testcase 6&7 */
    if ((TESTCASENAME.charAt(4) == '6') || (TESTCASENAME.charAt(4) == '7')) {
      DotsLogging.logMessage("Cleaning temporary file ...");

      if (!DotsConfig.RUN_AUTO) {
        System.out.println("Cleaning temporary file ...");
      }
      try {
        for (int j = 0; j < 10; j++) {
          File tmpFile = new File(lobFileName[j]);
          if (tmpFile.exists()) tmpFile.delete();
        }
      } catch (Exception e) {
        DotsLogging.logException("Clean temporary file error.");
      }
    }
    /* Write summary file and wait DB thread to exit */
    try {
      if (!DotsConfig.RUN_AUTO) {
        System.out.println("\nWriting summary file ...");
      }
      summary.writeSummaryFile();
      summary.canExit = true;
      DotsPerf.canExit = true;
      DotsLogging.logSummary("Waiting for the active threads to exit ......");
      if (!DotsConfig.RUN_AUTO) {
        System.out.println("\nWaiting for the active threads to exit ......");
      }
      while (DotsConfig.THRDGRP.activeCount() > 0) {
        waitInterval++;
        Thread.sleep(1000);
        if (!DotsConfig.RUN_AUTO) {
          System.out.println("Current active thread number is " + DotsConfig.THRDGRP.activeCount());
        }
        if (waitInterval > 60) break; // Max wait time is 1 minute
      }
    } catch (InterruptedException e) {
      DotsLogging.logException("Dots.main:" + e);
    }
    DotsLogging.logSummary("All Database Access Threads exit.");
    DotsLogging.close();
    if (!DotsConfig.RUN_AUTO) {
      System.out.println("DOTS closed successfully.");
    }
    System.exit(0);
  }
예제 #14
0
 private void iniciarCola() {
   Thread hilo = new Thread(this);
   hilo.setName("query_queue_PostgreSQL");
   hilo.start();
 }