Example #1
0
  /** Default Constructor */
  public DetIDGenerator() {
    query = new String();
    try {

      c = CDBConnection.getConnection();

      if (DetIDGenerator.export || DetIDGenerator.updateCB) {
        /*
          Just to check that we can connect to the export database
          Better to see it now rather than after all the computing...
        */
        configureExportDatabaseConnection();
        c.connect();
        c.disconnect();

        // Ok it's working, let's go!
      }

      c.setUser("prod_consult");
      c.setUrl(
          "jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ccdbcl01.in2p3.fr)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = ccdbcl02.in2p3.fr)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = cccmstrktaf.in2p3.fr)(FAILOVER_MODE =(TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))");
      c.setPassword("am8bilo8gy");

      c.connect();
    } catch (java.sql.SQLException e) {
      Error("SQL Error : \n" + query + "\n" + e.getMessage());
    } catch (java.lang.ClassNotFoundException e) {
      Error("Can not find Oracle driver");
    }
  }
Example #2
0
  private synchronized void retrieve(String criteria, boolean countOnly) throws DataStoreException {
    if (!countOnly) reset();
    waitForCancel(); // just in case there was already a retrieve running wait for it to be
                     // cancelled before continuing
    _retrieveInProgress = true;

    try {
      _dataSource.preRetrieve(this, criteria, countOnly);
    } catch (Exception e) {
      try {
        _dataSource.postRetrieve(this);
      } catch (java.sql.SQLException ex) {
        throw new DataStoreException(ex.toString(), ex);
      } catch (Exception ex) {
        throw new DataStoreException(ex.toString());
      }
      _retrieveInProgress = false;
      interruptWaitingRetrieveThreads();
      throw new DataStoreException(e.toString(), e);
    }

    if (!countOnly) {
      if (_threaded) {
        Thread t = new Thread(this);
        t.start();
      } else run();
    }
  }
Example #3
0
  /**
   * Perform the treatment :
   *
   * <ul>
   *   <li>Get the Det IDs for TEC and TOB
   *   <li>Get the DCU IDs associated to the module IDs
   *   <li>Get the fiber's length
   *   <li>Get the number of APVs
   *   <li>Export the data to a DB or print them on the screen
   * </ul>
   */
  public void go() {
    try {
      ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>();
      IDetIdGenerator tec = new TECAnalyzer();
      IDetIdGenerator tob = new TOBAnalyzer();

      list.addAll(tec.getDetIds());
      list.addAll(tob.getDetIds());

      if (DetIDGenerator.verbose) System.out.println(list.size() + " modules found");

      if (!DetIDGenerator.updateCB) {
        if (DetIDGenerator.verbose) System.out.println("Retrieving the fibers length...");
        getFiberLength(list);
      }

      if (DetIDGenerator.verbose) System.out.println("Converting DetIds to 32 bits...");
      compactDetIds(list);

      if (!DetIDGenerator.updateCB) {
        if (DetIDGenerator.verbose) System.out.println("Retrieving the number of APVs...");
        getApvNumber(list);
      }

      if (DetIDGenerator.verbose) System.out.println("Searching the DCU ids...");
      getDCU(list);

      if (DetIDGenerator.verbose) System.out.println("Reversing the DCU ids...");
      reverseDcuIds(list);

      if (!DetIDGenerator.updateCB) {
        if (DetIDGenerator.verbose) System.out.println("Exporting...");
        exportData(list);
      } else {
        System.out.println("updating the construction DB...");
        updateConstructionDB(list);
      }

      c.disconnect();

    } catch (java.sql.SQLException e) {
      Error("SQL Error : \n" + query + "\n" + e.getMessage());
    } catch (ClassNotSupportedException e) {
      Error("ClassNotSupportedException :\n" + e.getMessage());
    } catch (java.lang.ClassNotFoundException e) {
      Error("Can not find Oracle driver");
    } catch (Exception e) {
      Error("Error : \n" + e.getMessage());
    }
  }
Example #4
0
 /**
  * Main method used for test.<br>
  * Load a file (argument) with a list of dcu_id and check if we have the corresponding det_id.
  */
 public static void main(String args[]) {
   try {
     DetIDGenerator d = new DetIDGenerator();
     d.exportData(
         new ArrayList<ArrayList<String>>()); // only to connect to the configuration DB...
     ArrayList<Integer> dcuIds = loadFile(args[0]);
     System.out.println(dcuIds.size() + " modules : ");
     for (Integer dcuId : dcuIds) {
       try {
         System.out.println(dcuId + " -> " + d.getDetId(dcuId));
       } catch (java.sql.SQLException e) {
         System.out.print(e.getMessage());
       }
     }
   } catch (java.io.FileNotFoundException e2) {
     System.out.println(e2.getMessage());
   } catch (java.io.IOException e) {
     System.out.println("Error while reading the file: \n" + e.getMessage());
   } catch (java.sql.SQLException e) {
     System.out.print(e.getMessage());
   }
 }