Example #1
0
 void updateMenus() {
   if (IJ.debugMode) {
     long start = System.currentTimeMillis();
     Menus.updateImageJMenus();
     IJ.log("Refresh Menus: " + (System.currentTimeMillis() - start) + " ms");
   } else Menus.updateImageJMenus();
 }
 /**
  * This method runs the Runnable and measures how long it takes.
  *
  * @param r is the Runnable for the task that we want to measure
  * @return the time it took to execute this task
  */
 public static long time(Runnable r) {
   long time = -System.currentTimeMillis();
   r.run();
   time += System.currentTimeMillis();
   System.out.println("Took " + time + "ms");
   return time;
 }
Example #3
0
  public Connection executeBatch() throws Sql2oException {
    long start = System.currentTimeMillis();
    try {
      logExecution();
      PreparedStatement statement = buildPreparedStatement();
      connection.setBatchResult(statement.executeBatch());
      this.currentBatchRecords = 0;
      try {
        connection.setKeys(this.returnGeneratedKeys ? statement.getGeneratedKeys() : null);
        connection.setCanGetKeys(this.returnGeneratedKeys);
      } catch (SQLException sqlex) {
        throw new Sql2oException(
            "Error while trying to fetch generated keys from database. If you are not expecting any generated keys, fix this error by setting the fetchGeneratedKeys parameter in the createQuery() method to 'false'",
            sqlex);
      }
    } catch (Throwable e) {
      this.connection.onException();
      throw new Sql2oException("Error while executing batch operation: " + e.getMessage(), e);
    } finally {
      closeConnectionIfNecessary();
    }

    long end = System.currentTimeMillis();
    logger.debug(
        "total: {} ms; executed batch [{}]",
        new Object[] {end - start, this.getName() == null ? "No name" : this.getName()});

    return this.connection;
  }
 private void premain(Provider p) throws Exception {
   long start = System.currentTimeMillis();
   System.out.println("Running test with provider " + p.getName() + "...");
   main(p);
   long stop = System.currentTimeMillis();
   System.out.println(
       "Completed test with provider " + p.getName() + " (" + (stop - start) + " ms).");
 }
Example #5
0
 public ResultSetIterableBase() {
   try {
     start = System.currentTimeMillis();
     logExecution();
     rs = buildPreparedStatement().executeQuery();
     afterExecQuery = System.currentTimeMillis();
   } catch (SQLException ex) {
     throw new Sql2oException("Database error: " + ex.getMessage(), ex);
   }
 }
Example #6
0
 public Graph(WeightedBVGraph graph, String[] names) {
   org.apache.log4j.Logger logger =
       org.apache.log4j.Logger.getLogger("it.unimi.dsi.webgraph.ImmutableGraph");
   logger.setLevel(org.apache.log4j.Level.FATAL);
   if (names.length != graph.numNodes())
     throw new Error("Problem with the list of names for the nodes in the graph.");
   try {
     File auxFile = File.createTempFile("graph-maps-" + System.currentTimeMillis(), "aux");
     auxFile.deleteOnExit();
     RecordManager recMan = RecordManagerFactory.createRecordManager(auxFile.getAbsolutePath());
     nodes = recMan.hashMap("nodes");
     nodesReverse = recMan.hashMap("nodesReverse");
   } catch (IOException ex) {
     throw new Error(ex);
   }
   nodes.clear();
   nodesReverse.clear();
   Constructor[] cons = WeightedArc.class.getDeclaredConstructors();
   for (int i = 0; i < cons.length; i++) cons[i].setAccessible(true);
   this.graph = graph;
   WeightedArcSet list = new WeightedArcSet();
   ArcLabelledNodeIterator it = graph.nodeIterator();
   while (it.hasNext()) {
     if (commit++ % COMMIT_SIZE == 0) {
       commit();
       list.commit();
     }
     Integer aux1 = it.nextInt();
     Integer aux2 = null;
     ArcLabelledNodeIterator.LabelledArcIterator suc = it.successors();
     while ((aux2 = suc.nextInt()) != null && aux2 >= 0 && (aux2 < graph.numNodes()))
       try {
         WeightedArc arc = (WeightedArc) cons[0].newInstance(aux2, aux1, suc.label().getFloat());
         list.add(arc);
         this.nodes.put(aux1, names[aux1]);
         this.nodes.put(aux2, names[aux2]);
         this.nodesReverse.put(names[aux1], aux1);
         this.nodesReverse.put(names[aux2], aux2);
       } catch (Exception ex) {
         throw new Error(ex);
       }
   }
   reverse = new WeightedBVGraph(list.toArray(new WeightedArc[0]));
   numArcs = list.size();
   iterator = nodeIterator();
   try {
     File auxFile = File.createTempFile("graph" + System.currentTimeMillis(), "aux");
     auxFile.deleteOnExit();
     String basename = auxFile.getAbsolutePath();
     store(basename);
   } catch (IOException ex) {
     throw new Error(ex);
   }
   commit();
 }
Example #7
0
 private void chkFPS() {
   if (fpsCount == 0) {
     fpsTime = System.currentTimeMillis() / 1000;
     fpsCount++;
     return;
   }
   fpsCount++;
   long time = System.currentTimeMillis() / 1000;
   if (time != fpsTime) {
     lastFPS = fpsCount;
     fpsCount = 1;
     fpsTime = time;
   }
 }
Example #8
0
    @Override
    public void close() {
      try {
        if (rs != null) {
          rs.close();

          // log the query
          long afterClose = System.currentTimeMillis();
          logger.debug(
              "total: {} ms, execution: {} ms, reading and parsing: {} ms; executed [{}]",
              new Object[] {
                afterClose - start, afterExecQuery - start, afterClose - afterExecQuery, name
              });

          rs = null;
        }
      } catch (SQLException ex) {
        throw new Sql2oException("Error closing ResultSet.", ex);
      } finally {
        if (this.isAutoCloseConnection()) {
          connection.close();
        } else {
          closeConnectionIfNecessary();
        }
      }
    }
  /**
   * Sets the time in milliseconds of the last activity related to this <tt>Conference</tt> to the
   * current system time.
   */
  public void touch() {
    long now = System.currentTimeMillis();

    synchronized (this) {
      if (getLastActivityTime() < now) lastActivityTime = now;
    }
  }
Example #10
0
class ConnectionWrapper implements InvocationHandler {
  private static final String CLOSE_METHOD_NAME = "close";
  public Connection connection = null;
  private Connection m_originConnection = null;
  public long lastAccessTime = System.currentTimeMillis();
  Throwable debugInfo = new Throwable("Connection initial statement");

  ConnectionWrapper(Connection con) {
    this.connection =
        (Connection)
            Proxy.newProxyInstance(
                con.getClass().getClassLoader(), con.getClass().getInterfaces(), this);
    m_originConnection = con;
  }

  void close() throws SQLException {
    m_originConnection.close();
  }

  public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
    Object obj = null;
    if (CLOSE_METHOD_NAME.equals(m.getName())) {
      SimpleConnectionPool.pushConnectionBackToPool(this);
    } else {
      obj = m.invoke(m_originConnection, args);
    }
    lastAccessTime = System.currentTimeMillis();
    return obj;
  }
}
    DataContextImpl(OptiqConnectionImpl connection, List<Object> parameterValues) {
      this.queryProvider = connection;
      this.typeFactory = connection.getTypeFactory();
      this.rootSchema = connection.rootSchema;

      // Store the time at which the query started executing. The SQL
      // standard says that functions such as CURRENT_TIMESTAMP return the
      // same value throughout the query.
      final long time = System.currentTimeMillis();
      final TimeZone timeZone = connection.getTimeZone();
      final long localOffset = timeZone.getOffset(time);
      final long currentOffset = localOffset;

      ImmutableMap.Builder<Object, Object> builder = ImmutableMap.builder();
      builder
          .put("utcTimestamp", time)
          .put("currentTimestamp", time + currentOffset)
          .put("localTimestamp", time + localOffset)
          .put("timeZone", timeZone);
      for (Ord<Object> value : Ord.zip(parameterValues)) {
        Object e = value.e;
        if (e == null) {
          e = AvaticaParameter.DUMMY_VALUE;
        }
        builder.put("?" + value.i, e);
      }
      map = builder.build();
    }
Example #12
0
 public static Factory gettype(String name) {
   long start = System.currentTimeMillis();
   Factory f;
   try {
     f = gettype2(name);
   } catch (InterruptedException e) {
     /* XXX: This is not proper behavior. On the other hand,
      * InterruptedException should not be checked. :-/ */
     throw (new RuntimeException(
         "Interrupted while loading resource widget (took "
             + (System.currentTimeMillis() - start)
             + " ms)",
         e));
   }
   if (f == null) throw (new RuntimeException("No such widget type: " + name));
   return (f);
 }
  // The default constructor
  public CrownCounselIndexGetList_Access() {
    String traceProp = null;
    if ((traceProp = System.getProperty(HOSTPUBLISHER_ACCESSBEAN_TRACE)) != null) {
      try {
        Class c = Class.forName(HOSTPUBLISHER_ACCESSTRACE_OBJECT);
        Method m = c.getMethod("getInstance", null);
        o = m.invoke(null, null);
        Class parmTypes[] = {String.class};
        m = c.getMethod("initTrace", parmTypes);
        Object initTraceArgs[] = {traceProp};
        BitSet tracingBS = (BitSet) m.invoke(o, initTraceArgs);
        Class parmTypes2[] = {Object.class, String.class};
        traceMethod = c.getMethod("trace", parmTypes2);
        tracing = tracingBS.get(HOSTPUBLISHER_ACCESSBEAN_TRACING);
        Class parmTypes3[] = {String.class, HttpSession.class};
        auditMethod = c.getMethod("audit", parmTypes3);
        auditing = tracingBS.get(HOSTPUBLISHER_ACCESSBEAN_AUDITING);
      } catch (Exception e) {
        // no tracing will be done
        System.err.println(
            (new Date(System.currentTimeMillis())).toString()
                + " hostpublisher.accessbean.trace="
                + traceProp
                + ", Exception="
                + e.toString());
      }
    }

    if (tracing == true) {
      traceArgs[0] = this;
      traceArgs[1] = " CrownCounselIndexGetList_Access()";
      try {
        traceMethod.invoke(o, traceArgs);
      } catch (Exception x) {
        System.err.println(
            (new Date(System.currentTimeMillis())).toString()
                + " traceMethod.invoke(null, traceArgs)"
                + ", Exception="
                + x.toString());
      }
    }
    inputProps = new CrownCounselIndexGetList_Properties();
    return;
  }
Example #14
0
 public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
   Object obj = null;
   if (CLOSE_METHOD_NAME.equals(m.getName())) {
     SimpleConnectionPool.pushConnectionBackToPool(this);
   } else {
     obj = m.invoke(m_originConnection, args);
   }
   lastAccessTime = System.currentTimeMillis();
   return obj;
 }
Example #15
0
 /**
  * Implements {@link ActiveSpeakerChangedListener#activeSpeakerChanged(long)}. Notifies this
  * <tt>RecorderRtpImpl</tt> that the audio <tt>ReceiveStream</tt> considered active has changed,
  * and that the new active stream has SSRC <tt>ssrc</tt>.
  *
  * @param ssrc the SSRC of the new active stream.
  */
 @Override
 public void activeSpeakerChanged(long ssrc) {
   if (eventHandler != null) {
     RecorderEvent e = new RecorderEvent();
     e.setAudioSsrc(ssrc);
     // TODO: how do we time this?
     e.setInstant(System.currentTimeMillis());
     e.setType(RecorderEvent.Type.SPEAKER_CHANGED);
     e.setMediaType(MediaType.VIDEO);
     eventHandler.handleEvent(e);
   }
 }
Example #16
0
  public Connection executeUpdate() {
    long start = System.currentTimeMillis();
    try {
      logExecution();
      PreparedStatement statement = buildPreparedStatement();
      this.connection.setResult(statement.executeUpdate());
      this.connection.setKeys(this.returnGeneratedKeys ? statement.getGeneratedKeys() : null);
      connection.setCanGetKeys(this.returnGeneratedKeys);
    } catch (SQLException ex) {
      this.connection.onException();
      throw new Sql2oException("Error in executeUpdate, " + ex.getMessage(), ex);
    } finally {
      closeConnectionIfNecessary();
    }

    long end = System.currentTimeMillis();
    logger.debug(
        "total: {} ms; executed update [{}]",
        new Object[] {end - start, this.getName() == null ? "No name" : this.getName()});

    return this.connection;
  }
Example #17
0
  public Object executeScalar() {
    long start = System.currentTimeMillis();
    try {
      logExecution();
      ResultSet rs = buildPreparedStatement().executeQuery();
      if (rs.next()) {
        Object o = getQuirks().getRSVal(rs, 1);
        long end = System.currentTimeMillis();
        logger.debug(
            "total: {} ms; executed scalar [{}]",
            new Object[] {end - start, this.getName() == null ? "No name" : this.getName()});
        return o;
      } else {
        return null;
      }

    } catch (SQLException e) {
      this.connection.onException();
      throw new Sql2oException(
          "Database error occurred while running executeScalar: " + e.getMessage(), e);
    } finally {
      closeConnectionIfNecessary();
    }
  }
 /**
  * Removes dirty entries from the cache. Calling System.currentTimeMillis() is costly so we
  * should try to limit calls to this method. This method will only trigger cleanup at most once
  * per 30s.
  */
 private void removeDirtyEntries() {
   long now = System.currentTimeMillis();
   if (now - lastCleanup < MINIMAL_CLEANUP_INTERVAL) {
     return;
   }
   lock.writeLock().lock();
   try {
     for (MethodInvocationKey key : new LinkedList<MethodInvocationKey>(store.keySet())) {
       if (key.isDirty()) {
         evict++;
         store.remove(key);
       }
     }
   } finally {
     lastCleanup = now;
     lock.writeLock().unlock();
   }
 }
Example #19
0
  private static void clearClosedConnection() {
    long time = System.currentTimeMillis();
    // sometimes user change system time,just return
    if (time < m_lastClearClosedConnection) {
      m_lastClearClosedConnection = time;
      return;
    }
    // no need check very often
    if (time - m_lastClearClosedConnection < CHECK_CLOSED_CONNECTION_TIME) {
      return;
    }
    m_lastClearClosedConnection = time;

    // begin check
    Iterator iterator = m_notUsedConnection.iterator();
    while (iterator.hasNext()) {
      ConnectionWrapper wrapper = (ConnectionWrapper) iterator.next();
      try {
        if (wrapper.connection.isClosed()) {
          iterator.remove();
        }
      } catch (Exception e) {
        iterator.remove();
        if (DEBUG) {
          System.out.println("connection is closed, this connection initial StackTrace");
          wrapper.debugInfo.printStackTrace();
        }
      }
    }

    // make connection pool size smaller if too big
    int decrease = getDecreasingConnectionCount();
    if (m_notUsedConnection.size() < decrease) {
      return;
    }

    while (decrease-- > 0) {
      ConnectionWrapper wrapper = (ConnectionWrapper) m_notUsedConnection.removeFirst();
      try {
        wrapper.connection.close();
      } catch (Exception e) {
      }
    }
  }
Example #20
0
  public CompositeData getNextEntry(Object[] indexObjects) {

    // User code starts here
    if (!agentName.initAlert()) return null;

    String previousKeys[] = {indexObjects[0].toString(), indexObjects[1].toString()};
    String keys[] = getNextAlert(previousKeys);

    if (keys == null) return null;

    String source = keys[0];

    // String ownerName = keys[1];

    String entity = keys[1];

    Alert alert1 = new Alert();

    alert1.setSource(source);

    //	alert1.setOwnerName(ownerName);

    alert1.setEntity(entity);

    Alert alert2 = new Alert();

    alert2.setModTime(System.currentTimeMillis());

    Vector alerts = null;

    try {
      alerts = agentName.alertAPI.getAlerts(alert1, alert2);

      if (alerts != null) return makeComData((Alert) alerts.elementAt(0));
    } catch (Exception e) {
      return null;
    }

    // User code ends here
    return null;
  }
Example #21
0
  /**
   * Inserts a Clob with the specified length, using a stream source, then fetches it from the
   * database and checks the length.
   *
   * @param length number of characters in the Clob
   * @throws IOException if reading from the source fails
   * @throws SQLException if something goes wrong
   */
  private void insertAndFetchTest(long length) throws IOException, SQLException {
    PreparedStatement ps = prepareStatement("insert into BLOBCLOB(ID, CLOBDATA) values(?,?)");
    int id = BlobClobTestSetup.getID();
    ps.setInt(1, id);
    ps.setCharacterStream(2, new LoopingAlphabetReader(length), length);
    long tsStart = System.currentTimeMillis();
    ps.execute();
    println(
        "Inserted "
            + length
            + " chars (length specified) in "
            + (System.currentTimeMillis() - tsStart)
            + " ms");
    Statement stmt = createStatement();
    tsStart = System.currentTimeMillis();
    ResultSet rs = stmt.executeQuery("select CLOBDATA from BLOBCLOB where id = " + id);
    assertTrue("Clob not inserted", rs.next());
    Clob aClob = rs.getClob(1);
    assertEquals("Invalid length", length, aClob.length());
    println("Fetched length (" + length + ") in " + (System.currentTimeMillis() - tsStart) + " ms");
    rs.close();

    // Insert same Clob again, using the lengthless override.
    id = BlobClobTestSetup.getID();
    ps.setInt(1, id);
    ps.setCharacterStream(2, new LoopingAlphabetReader(length));
    tsStart = System.currentTimeMillis();
    ps.executeUpdate();
    println(
        "Inserted "
            + length
            + " chars (length unspecified) in "
            + (System.currentTimeMillis() - tsStart)
            + " ms");
    rs = stmt.executeQuery("select CLOBDATA from BLOBCLOB where id = " + id);
    assertTrue("Clob not inserted", rs.next());
    aClob = rs.getClob(1);
    assertEquals("Invalid length", length, aClob.length());
    println("Fetched length (" + length + ") in " + (System.currentTimeMillis() - tsStart) + " ms");
    rs.close();

    rollback();
  }
Example #22
0
File: Macro.java Project: bramk/bnd
  public String _tstamp(String args[]) {
    String format = "yyyyMMddHHmm";
    long now = System.currentTimeMillis();
    TimeZone tz = TimeZone.getTimeZone("UTC");

    if (args.length > 1) {
      format = args[1];
    }
    if (args.length > 2) {
      tz = TimeZone.getTimeZone(args[2]);
    }
    if (args.length > 3) {
      now = Long.parseLong(args[3]);
    }
    if (args.length > 4) {
      domain.warning("Too many arguments for tstamp: " + Arrays.toString(args));
    }

    SimpleDateFormat sdf = new SimpleDateFormat(format);
    sdf.setTimeZone(tz);

    return sdf.format(new Date(now));
  }
 private void endHereCommon() throws BeanException {
   // save EJB object handle in property
   if (ejb != null) {
     try {
       hPubAccessHandle = ejb.getHandle();
     } catch (Exception e) {
       String errMsg =
           (new Date(System.currentTimeMillis())).toString()
               + " HPS5955 "
               + this.getClass().getName()
               + ": ejb.getHandle(), ejb="
               + ejb
               + ": "
               + e.getClass().getName()
               + ": "
               + e.getMessage();
       System.err.println(errMsg);
       if (tracing == true) {
         traceArgs[0] = this;
         traceArgs[1] = errMsg;
         try {
           traceMethod.invoke(o, traceArgs);
         } catch (Exception x) {
         }
       }
       throw new BeanException(errMsg);
     }
   }
   // save ejb accessHandle and hpubLinkKey in HttpSession
   if ((oHttpServletRequest != null) && (outputProps != null)) {
     // a new HPubEjb2HttpSessionBindingListener object containing the ejb access
     // handle and hPubLinkKey for the connection is bound to the session using
     // a prefix and the ending connection state of the IO just processed.
     // This hPubLinkKey uniquely identifies the connection associated with the
     // IO chain for that HP Runtime JVM.
     // The ejb access handle is contained within the HPubEjb2HttpSessionBindingListener
     // object so that an ejb remove can be issued in the case where a session
     // timeout or session invalidation occurs for an incomplete IO chain.
     HttpSession theWebsession = oHttpServletRequest.getSession(true);
     if (theWebsession != null) {
       synchronized (theWebsession) {
         try {
           String theKey = KEY_WEBCONN + outputProps.getHPubEndChainName();
           hPubLinkKey = outputProps.getHPubLinkKey();
           theWebsession.setAttribute(
               theKey, new HPubEJB2HttpSessionBindingListener(hPubAccessHandle, hPubLinkKey));
           if (tracing == true) {
             traceArgs[0] = this;
             traceArgs[1] =
                 "theWebsession.setAttribute("
                     + theKey
                     + ",new HPubEJB2HttpSessionBindingListener("
                     + hPubAccessHandle
                     + ", "
                     + hPubLinkKey
                     + "))";
             try {
               traceMethod.invoke(o, traceArgs);
             } catch (Exception x) {
             }
           }
           if (auditing == true) {
             auditArgs[0] =
                 "\n---\nIN:"
                     + this.getClass().getName()
                     + " "
                     + theKey
                     + " "
                     + hPubAccessHandle
                     + " "
                     + hPubLinkKey
                     + " "
                     + theWebsession.getId();
             auditArgs[1] = theWebsession;
             try {
               auditMethod.invoke(o, auditArgs);
             } catch (Exception x) {
             }
           }
         } catch (Exception e) {
           hPubLinkKey = null; // set to null to force following error logic
         }
       }
     }
     // if an error occurred throw an exception to cause ejb remove to be issued.
     if ((theWebsession == null) || (hPubLinkKey == null)) {
       String errMsg =
           (new Date(System.currentTimeMillis())).toString()
               + " HPS5956 "
               + this.getClass().getName()
               + ": HttpServletRequest.getSession(true), hPubLinkKey="
               + hPubLinkKey;
       System.err.println(errMsg);
       if (tracing == true) {
         traceArgs[0] = this;
         traceArgs[1] = errMsg;
         try {
           traceMethod.invoke(o, traceArgs);
         } catch (Exception x) {
         }
       }
       throw new BeanException(errMsg);
     }
   }
   // send Event to User indicating that the Query request is complete
   RequestCompleteEvent hPubEvent = new RequestCompleteEvent(this);
   fireHPubReqCompleteEvent(hPubEvent);
   return;
 }
  /** all processing methods end up here */
  private void startHereCommon() throws BeanException {
    // try to get the linkKey if already set in input properties
    try {
      hPubLinkKey = inputProps.getHPubLinkKey();
    } catch (Exception e) {
    }

    // if running in Web environment and either the ejb access handle or
    // the linkKey are null, try to get them from the HttpSession
    if (oHttpServletRequest != null) {
      HttpSession theWebsession = oHttpServletRequest.getSession(false);
      if (theWebsession != null) {
        synchronized (theWebsession) {
          try {
            if (tracing == true) {
              traceArgs[0] = this;
              traceArgs[1] = "HttpSession.getId()=" + theWebsession.getId();
              try {
                traceMethod.invoke(o, traceArgs);
              } catch (Exception x) {
              }
            }
            String theKey = KEY_WEBCONN + inputProps.getHPubStartChainName();
            // if linkKey or access handle is null try to get it from Websession
            HPubEJB2HttpSessionBindingListener sbl =
                (HPubEJB2HttpSessionBindingListener) theWebsession.getAttribute(theKey);
            if ((hPubLinkKey == null) && (sbl != null)) {
              hPubLinkKey = sbl.getLinkKey();
              if (tracing == true) {
                traceArgs[0] = this;
                traceArgs[1] = "HttpSession.getAttribute(hPubLinkKey)=" + hPubLinkKey;
                try {
                  traceMethod.invoke(o, traceArgs);
                } catch (Exception x) {
                }
              }
              inputProps.setHPubLinkKey(hPubLinkKey);
            }
            if ((hPubAccessHandle == null) && (sbl != null)) {
              hPubAccessHandle = sbl.getEjbHandle();
              if (tracing == true) {
                traceArgs[0] = this;
                traceArgs[1] = "HttpSession.getAttribute(hPubAccessHandle)=" + hPubAccessHandle;
                try {
                  traceMethod.invoke(o, traceArgs);
                } catch (Exception x) {
                }
              }
            }
            // set the ejb handle to null before removing the Session Binding
            // Listener object
            if (auditing == true) {
              if (sbl != null)
                auditArgs[0] =
                    "\n---\nOUT:"
                        + this.getClass().getName()
                        + " "
                        + theKey
                        + " "
                        + hPubAccessHandle
                        + " "
                        + hPubLinkKey
                        + " "
                        + theWebsession.getId();
              else // error - object not found in HttpSession
              auditArgs[0] =
                    "\n---\nERR:"
                        + this.getClass().getName()
                        + " "
                        + theKey
                        + " "
                        + theWebsession.getId();

              auditArgs[1] = theWebsession;
              try {
                auditMethod.invoke(o, auditArgs);
              } catch (Exception x) {
              }
            }
            if (sbl != null) sbl.setEjbHandle(null);
            theWebsession.removeAttribute(theKey);
          } catch (IllegalStateException e) {
          }
        }
      }
    }
    // if either of required properties are still null then the ejb cannot
    // be accessed - throw an exception.
    if ((hPubAccessHandle == null) || (hPubLinkKey == null)) {
      String errMsg =
          (new Date(System.currentTimeMillis())).toString()
              + " HPS5951 "
              + this.getClass().getName()
              + ": hPubAccessHandle==null || hPubLinkKey==null";
      System.err.println(errMsg);
      if (tracing == true) {
        traceArgs[0] = this;
        traceArgs[1] = errMsg;
        try {
          traceMethod.invoke(o, traceArgs);
        } catch (Exception x) {
        }
      }
      throw new BeanException(errMsg);
    } else {
      if (tracing == true) {
        traceArgs[0] = this;
        traceArgs[1] = "hPubAccessHandle=" + hPubAccessHandle + ",hPubLinkKey=" + hPubLinkKey;
        try {
          traceMethod.invoke(o, traceArgs);
        } catch (Exception x) {
        }
      }
    }

    // get the EJB object from the handle
    try {
      ejb =
          (com.ibm.HostPublisher.EJB.HPubEJB2)
              javax.rmi.PortableRemoteObject.narrow(
                  hPubAccessHandle.getEJBObject(), com.ibm.HostPublisher.EJB.HPubEJB2.class);
    } catch (Exception e) {
      String errMsg =
          (new Date(System.currentTimeMillis())).toString()
              + " HPS5952 "
              + this.getClass().getName()
              + ": getEJBObject(): "
              + e.getClass().getName()
              + ": "
              + e.getMessage();
      System.err.println(errMsg);
      if (tracing == true) {
        traceArgs[0] = this;
        traceArgs[1] = errMsg;
        try {
          traceMethod.invoke(o, traceArgs);
        } catch (Exception x) {
        }
      }
      throw new BeanException(errMsg);
    }
    // if ejb handle, go invoke the HPubEJB's main business method.
    if (ejb != null) {
      try {
        outputProps = (CrownCounselIndexGetList_Properties) ejb.processIO(inputProps);
        inputProps = outputProps;
        inputProps.setInitialCall(false);
      } catch (Exception e) {
        String errMsg =
            (new Date(System.currentTimeMillis())).toString()
                + " HPS5953 "
                + this.getClass().getName()
                + ": processIO("
                + inputProps.getClass().getName()
                + "): "
                + e.getClass().getName()
                + ": "
                + e.getMessage();
        System.err.println(errMsg);
        if (tracing == true) {
          traceArgs[0] = this;
          traceArgs[1] = errMsg;
          try {
            traceMethod.invoke(o, traceArgs);
          } catch (Exception x) {
          }
        }
        throw new BeanException(errMsg);
      }
    }
    endHereCommon();
    return;
  }
Example #25
0
 public Graph neighbourhoodGraph(int nnodes[], int hops) {
   PrimaryHashMap<Integer, String> nodes;
   PrimaryHashMap<String, Integer> nodesReverse;
   try {
     File auxFile = File.createTempFile("graph-maps-" + System.currentTimeMillis(), "aux");
     auxFile.deleteOnExit();
     RecordManager recMan = RecordManagerFactory.createRecordManager(auxFile.getAbsolutePath());
     nodes = recMan.hashMap("nodes");
     nodesReverse = recMan.hashMap("nodesReverse");
   } catch (IOException ex) {
     throw new Error(ex);
   }
   nodes.clear();
   nodesReverse.clear();
   WeightedArcSet list1 = new WeightedArcSet();
   Int2IntAVLTreeMap map = new Int2IntAVLTreeMap();
   IntSet set = new IntLinkedOpenHashSet();
   int numIterators = 100;
   Constructor[] cons = WeightedArc.class.getDeclaredConstructors();
   for (int i = 0; i < cons.length; i++) cons[i].setAccessible(true);
   for (int n : nnodes) map.put(n, 0);
   NodeIterator its[] = new NodeIterator[numIterators];
   int itNum[] = new int[numIterators];
   for (int n = 0; n < its.length; n++) {
     its[n] = nodeIterator();
     itNum[n] = 0;
   }
   while (map.size() != 0) {
     Integer node = 0;
     for (int n = 0; n < its.length; n++) if (itNum[n] <= node) node = itNum[n];
     node = map.tailMap(node).firstKey();
     if (node == null) map.firstKey();
     NodeIterator it = null;
     Integer aux1 = 0;
     int iit = 0;
     for (int n = 0; n < its.length; n++) {
       if (!its[n].hasNext()) {
         its[n] = nodeIterator();
         itNum[n] = 0;
       }
       if (itNum[n] == node) {
         it = its[n];
         aux1 = itNum[n];
         iit = 0;
         break;
       }
       if (itNum[n] < node && itNum[n] >= aux1) {
         it = its[n];
         aux1 = itNum[n];
         iit = n;
       }
     }
     if (it == null) {
       its[0] = nodeIterator();
       itNum[0] = 0;
       it = its[0];
     }
     while (it != null && (aux1 = it.nextInt()) != null && aux1 >= 0 && aux1 < node) {}
     itNum[iit] = aux1 + 1;
     Integer aux2 = null;
     ArcLabelledNodeIterator.LabelledArcIterator suc = it.successors();
     while ((aux2 = suc.nextInt()) != null && aux2 >= 0 && (aux2 < graph.numNodes()))
       try {
         if (commit++ % COMMIT_SIZE == 0) {
           try {
             nodes.getRecordManager().commit();
           } catch (IOException e) {
             throw new Error(e);
           }
           try {
             nodesReverse.getRecordManager().commit();
           } catch (IOException e) {
             throw new Error(e);
           }
         }
         if (!nodesReverse.containsKey(this.nodes.get(aux1))) {
           nodes.put(nodes.size(), this.nodes.get(aux1));
           nodesReverse.put(this.nodes.get(aux1), nodesReverse.size());
         }
         if (!nodesReverse.containsKey(this.nodes.get(aux2))) {
           nodes.put(nodes.size(), this.nodes.get(aux2));
           nodesReverse.put(this.nodes.get(aux2), nodesReverse.size());
         }
         int aaux1 = nodesReverse.get(this.nodes.get(aux1));
         int aaux2 = nodesReverse.get(this.nodes.get(aux2));
         WeightedArc arc1 =
             (WeightedArc) cons[0].newInstance(aaux1, aaux2, suc.label().getFloat());
         list1.add(arc1);
         if (map.get(node) < hops) {
           if (!set.contains(aux1) && (map.get(aux1) == null || map.get(aux1) > map.get(node) + 1))
             map.put(aux1.intValue(), map.get(node) + 1);
           if (!set.contains(aux2) && (map.get(aux2) == null || map.get(aux2) > map.get(node) + 1))
             map.put(aux2.intValue(), map.get(node) + 1);
         }
       } catch (Exception ex) {
         ex.printStackTrace();
         throw new Error(ex);
       }
     ArcLabelledNodeIterator.LabelledArcIterator anc = it.ancestors();
     while ((aux2 = anc.nextInt()) != null && aux2 >= 0 && (aux2 < graph.numNodes()))
       try {
         if (commit++ % COMMIT_SIZE == 0) {
           try {
             nodes.getRecordManager().commit();
           } catch (IOException e) {
             throw new Error(e);
           }
           try {
             nodesReverse.getRecordManager().commit();
           } catch (IOException e) {
             throw new Error(e);
           }
         }
         if (!nodesReverse.containsKey(this.nodes.get(aux1))) {
           nodes.put(nodes.size(), this.nodes.get(aux1));
           nodesReverse.put(this.nodes.get(aux1), nodesReverse.size());
         }
         if (!nodesReverse.containsKey(this.nodes.get(aux2))) {
           nodes.put(nodes.size(), this.nodes.get(aux2));
           nodesReverse.put(this.nodes.get(aux2), nodesReverse.size());
         }
         int aaux1 = nodesReverse.get(this.nodes.get(aux1));
         int aaux2 = nodesReverse.get(this.nodes.get(aux2));
         WeightedArc arc1 =
             (WeightedArc) cons[0].newInstance(aaux2, aaux1, anc.label().getFloat());
         list1.add(arc1);
         if (map.get(node) < hops) {
           if (!set.contains(aux1) && (map.get(aux1) == null || map.get(aux1) > map.get(node) + 1))
             map.put(aux1.intValue(), map.get(node) + 1);
           if (!set.contains(aux2) && (map.get(aux2) == null || map.get(aux2) > map.get(node) + 1))
             map.put(aux2.intValue(), map.get(node) + 1);
         }
       } catch (Exception ex) {
         ex.printStackTrace();
         throw new Error(ex);
       }
     map.remove(node);
     set.add(node);
   }
   Graph newGraph = new Graph(list1.toArray(new WeightedArc[0]));
   newGraph.nodes.clear();
   newGraph.nodesReverse.clear();
   newGraph.nodes = nodes;
   newGraph.nodesReverse = nodesReverse;
   return newGraph;
 }
Example #26
0
 public Graph(String file) throws IOException {
   org.apache.log4j.Logger logger =
       org.apache.log4j.Logger.getLogger("it.unimi.dsi.webgraph.ImmutableGraph");
   logger.setLevel(org.apache.log4j.Level.FATAL);
   try {
     File auxFile = File.createTempFile("graph-maps-" + System.currentTimeMillis(), "aux");
     auxFile.deleteOnExit();
     RecordManager recMan = RecordManagerFactory.createRecordManager(auxFile.getAbsolutePath());
     nodes = recMan.hashMap("nodes");
     nodesReverse = recMan.hashMap("nodesReverse");
   } catch (IOException ex) {
     throw new Error(ex);
   }
   nodes.clear();
   nodesReverse.clear();
   Constructor[] cons = WeightedArc.class.getDeclaredConstructors();
   for (int i = 0; i < cons.length; i++) cons[i].setAccessible(true);
   String aux = null;
   Float weight = (float) 1.0;
   WeightedArcSet list = new WeightedArcSet();
   BufferedReader br;
   try {
     br =
         new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file))));
   } catch (Exception ex) {
     br = new BufferedReader(new FileReader(file));
   }
   while ((aux = br.readLine()) != null)
     try {
       if (commit++ % COMMIT_SIZE == 0) {
         commit();
         list.commit();
       }
       String parts[] = aux.split("\t");
       String l1 = new String(parts[0]);
       String l2 = new String(parts[1]);
       if (!nodesReverse.containsKey(l1)) {
         nodesReverse.put(l1, nodesReverse.size());
         nodes.put(nodes.size(), l1);
       }
       if (!nodesReverse.containsKey(l2)) {
         nodesReverse.put(l2, nodesReverse.size());
         nodes.put(nodes.size(), l2);
       }
       if (parts.length == 3) weight = new Float(parts[2]);
       list.add(
           (WeightedArc) cons[0].newInstance(nodesReverse.get(l1), nodesReverse.get(l2), weight));
     } catch (Exception ex) {
       throw new Error(ex);
     }
   this.graph = new WeightedBVGraph(list.toArray(new WeightedArc[0]));
   br.close();
   list = new WeightedArcSet();
   br = new BufferedReader(new FileReader(file));
   while ((aux = br.readLine()) != null)
     try {
       if (commit++ % COMMIT_SIZE == 0) {
         commit();
         list.commit();
       }
       String parts[] = aux.split("\t");
       String l1 = new String(parts[0]);
       String l2 = new String(parts[1]);
       if (parts.length == 3) weight = new Float(parts[2]);
       list.add(
           (WeightedArc) cons[0].newInstance(nodesReverse.get(l2), nodesReverse.get(l1), weight));
     } catch (Exception ex) {
       throw new Error(ex);
     }
   br.close();
   this.reverse = new WeightedBVGraph(list.toArray(new WeightedArc[0]));
   numArcs = list.size();
   iterator = nodeIterator();
   try {
     File auxFile = File.createTempFile("graph" + System.currentTimeMillis(), "aux");
     auxFile.deleteOnExit();
     String basename = auxFile.getAbsolutePath();
     store(basename);
   } catch (IOException ex) {
     throw new Error(ex);
   }
   commit();
 }
Example #27
0
 public Graph(BVGraph graph) {
   org.apache.log4j.Logger logger =
       org.apache.log4j.Logger.getLogger("it.unimi.dsi.webgraph.ImmutableGraph");
   logger.setLevel(org.apache.log4j.Level.FATAL);
   try {
     File auxFile = File.createTempFile("graph-maps-" + System.currentTimeMillis(), "aux");
     auxFile.deleteOnExit();
     RecordManager recMan = RecordManagerFactory.createRecordManager(auxFile.getAbsolutePath());
     nodes = recMan.hashMap("nodes");
     nodesReverse = recMan.hashMap("nodesReverse");
   } catch (IOException ex) {
     throw new Error(ex);
   }
   nodes.clear();
   nodesReverse.clear();
   Constructor[] cons = WeightedArc.class.getDeclaredConstructors();
   for (int i = 0; i < cons.length; i++) cons[i].setAccessible(true);
   Integer aux1 = null;
   WeightedArcSet list = new WeightedArcSet();
   it.unimi.dsi.webgraph.NodeIterator it = graph.nodeIterator();
   while ((aux1 = it.nextInt()) != null) {
     LazyIntIterator suc = it.successors();
     Integer aux2 = null;
     while ((aux2 = suc.nextInt()) != null && aux2 >= 0 && (aux2 < graph.numNodes()))
       try {
         if (commit++ % COMMIT_SIZE == 0) {
           list.commit();
         }
         list.add((WeightedArc) cons[0].newInstance(aux1, aux2, (float) 1.0));
       } catch (Exception ex) {
         throw new Error(ex);
       }
   }
   this.graph = new WeightedBVGraph(list.toArray(new WeightedArc[0]));
   list = new WeightedArcSet();
   it = graph.nodeIterator();
   while ((aux1 = it.nextInt()) != null) {
     LazyIntIterator suc = it.successors();
     Integer aux2 = null;
     while ((aux2 = suc.nextInt()) != null && aux2 >= 0 && (aux2 < graph.numNodes()))
       try {
         if (commit++ % COMMIT_SIZE == 0) {
           commit();
           list.commit();
         }
         list.add((WeightedArc) cons[0].newInstance(aux2, aux1, (float) 1.0));
         this.nodes.put(aux1, "" + aux1);
         this.nodes.put(aux2, "" + aux2);
         this.nodesReverse.put("" + aux1, aux1);
         this.nodesReverse.put("" + aux2, aux2);
       } catch (Exception ex) {
         throw new Error(ex);
       }
   }
   this.reverse = new WeightedBVGraph(list.toArray(new WeightedArc[0]));
   numArcs = list.size();
   iterator = nodeIterator();
   try {
     File auxFile = File.createTempFile("graph" + System.currentTimeMillis(), "aux");
     auxFile.deleteOnExit();
     String basename = auxFile.getAbsolutePath();
     store(basename);
   } catch (IOException ex) {
     throw new Error(ex);
   }
   commit();
 }
Example #28
0
File: Macro.java Project: bramk/bnd
 public String _currenttime(@SuppressWarnings("unused") String args[]) {
   return Long.toString(System.currentTimeMillis());
 }
 public void setCurrent(String str) {
   this.str = str;
   sampleTime = System.currentTimeMillis();
 }
 public StringStatisticImpl(String name, String unit, String desc) {
   this("", name, unit, desc, System.currentTimeMillis(), System.currentTimeMillis());
 }