Ejemplo n.º 1
0
  public MRCStatusManager(MRCRequestDispatcher master) throws IOException {

    super("MRCStatusManager");

    this.master = master;

    knownMRCs = ServiceSet.newBuilder();
    mrcAddrMap = new HashMap<InetSocketAddress, String>();

    int interval = master.getConfig().getOsdCheckInterval();
    checkIntervalMillis = 1000 * interval;
  }
Ejemplo n.º 2
0
  /** Main loop. */
  public void run() {

    // initially fetch the list of MRCs from the Directory Service
    try {

      knownMRCs =
          master
              .getDirClient()
              .xtreemfs_service_get_by_type(
                  null,
                  RPCAuthentication.authNone,
                  RPCAuthentication.userService,
                  ServiceType.SERVICE_TYPE_MRC)
              .toBuilder();

    } catch (Throwable exc) {
      this.notifyCrashed(exc);
    }

    notifyStarted();
    if (Logging.isInfo())
      Logging.logMessage(
          Logging.LEVEL_INFO,
          Category.lifecycle,
          this,
          "MRC status manager operational, using DIR %s",
          master.getConfig().getDirectoryService().toString());

    while (!quit) {

      synchronized (this) {
        try {
          this.wait(
              knownMRCs == null || knownMRCs.getServicesCount() == 0
                  ? checkIntervalMillis / 2
                  : checkIntervalMillis);
        } catch (InterruptedException ex) {
          break;
        }
      }

      Logging.logMessage(
          Logging.LEVEL_DEBUG, Category.misc, this, "sending request for MRC list to DIR...");

      try {
        // request list of registered MRCs from Directory
        // Service

        knownMRCs =
            master
                .getDirClient()
                .xtreemfs_service_get_by_type(
                    null,
                    RPCAuthentication.authNone,
                    RPCAuthentication.userService,
                    ServiceType.SERVICE_TYPE_MRC)
                .toBuilder();

        Logging.logMessage(
            Logging.LEVEL_DEBUG, Category.misc, this, "... received MRC list from DIR");

        evaluateResponse(knownMRCs);

      } catch (InterruptedException ex) {
        break;
      } catch (Exception exc) {
        if (!quit)
          Logging.logMessage(
              Logging.LEVEL_ERROR, Category.misc, this, OutputUtils.stackTraceToString(exc));
      }

      synchronized (syncLock) {
        syncLock.notifyAll();
      }
    }

    notifyStopped();
  }