Ejemplo n.º 1
0
 private void startTimeBufferingThread() {
   String period = manager.getProperty(LogConstants.BUFFER_TIME);
   long interval;
   if ((period != null) || (period.length() != 0)) {
     interval = Long.parseLong(period);
   } else {
     interval = LogConstants.BUFFER_TIME_DEFAULT;
   }
   interval *= 1000;
   if (bufferTask == null) {
     bufferTask = new TimeBufferingTask(interval);
     try {
       SystemTimer.getTimer()
           .schedule(
               bufferTask, new Date(((System.currentTimeMillis() + interval) / 1000) * 1000));
     } catch (IllegalArgumentException e) {
       Debug.error(logName + ":RemoteHandler:BuffTimeArg: " + e.getMessage());
     } catch (IllegalStateException e) {
       if (Debug.messageEnabled()) {
         Debug.message(logName + ":RemoteHandler:BuffTimeState: " + e.getMessage());
       }
     }
     if (Debug.messageEnabled()) {
       Debug.message("RemoteHandler: Time Buffering Thread Started");
     }
   }
 }
Ejemplo n.º 2
0
  /**
   * Constructs an instance for the cluster service
   *
   * @param localServerId id of the server instance in which this ClusterStateService instance is
   *     running
   * @param timeout timeout for waiting on an individual server (millisec)
   * @param period checking cycle period (millisecs)
   * @param members map if server id - > url for all cluster members
   * @throws Exception
   */
  protected ClusterStateService(
      SessionService sessionService,
      String localServerId,
      int timeout,
      long period,
      Map<String, String> members)
      throws Exception {
    if ((localServerId == null) || (localServerId.isEmpty())) {
      String message =
          "ClusterStateService: Local Server Id argument is null, unable to instantiate Cluster State Service!";
      sessionDebug.error(message);
      throw new IllegalArgumentException(message);
    }
    // Ensure we Synchronize this Instantiation.
    synchronized (this) {
      this.sessionService = sessionService;
      this.localServerId = localServerId;
      this.timeout = timeout;
      this.period = period;
      serverSelectionList = new ServerInfo[members.size()];

      for (Map.Entry<String, String> entry : members.entrySet()) {
        ServerInfo info = new ServerInfo();
        info.id = entry.getKey();
        URL url = new URL(entry.getValue() + "/namingservice");
        info.url = url;
        info.protocol = url.getProtocol();
        info.address = new InetSocketAddress(url.getHost(), url.getPort());
        // Fix for Deadlock. If this is our server, set to true, else false.
        info.isUp = isLocalServerId(info.id);
        info.isLocal = info.isUp; // Set our Local Server Indicator, per above interrogation.

        // Check for Down Servers.
        if (!info.isUp) {
          downServers.add(info.id);
        }

        // Add Server to Server List.
        servers.put(info.id, info);
        // Associate to a Server Selection Bucket.
        serverSelectionList[getNextSelected()] = info;
        if (sessionDebug.messageEnabled()) {
          sessionDebug.error("Added Server to ClusterStateService: " + info.toString());
        }
      } // End of For Loop.

      // to ensure that ordering in different server instances is identical
      Arrays.sort(serverSelectionList);
      SystemTimer.getTimer().schedule(this, new Date((System.currentTimeMillis() / 1000) * 1000));
    } // End of Synchronized Block.
  }
Ejemplo n.º 3
0
  /**
   * Reset error searches. Clear cache only if true is passed to argument
   *
   * @param clearCaches
   */
  protected void resetErrorSearches(boolean clearCaches) {

    Hashtable tmpReqList = new Hashtable();
    tmpReqList.putAll(_requestList);

    int[] ids = _msgQueue.getMessageIDs();
    if (ids != null) {
      for (int i = 0; i < ids.length; i++) {
        String reqID = Integer.toString(ids[i]);
        tmpReqList.remove(reqID);
      }
    }
    Collection reqList = tmpReqList.values();
    for (Iterator iter = reqList.iterator(); iter.hasNext(); ) {
      Request req = (Request) iter.next();
      _requestList.remove(req.getRequestID());
    }
    _retryInterval = getPropertyIntValue(EVENT_CONNECTION_RETRY_INTERVAL, _retryInterval);
    RetryTask task = new RetryTask(tmpReqList);
    task.clearCache(clearCaches);
    SystemTimer.getTimer()
        .schedule(task, new Date(((System.currentTimeMillis() + _retryInterval) / 1000) * 1000));
  }