public static void initRecovery(boolean force) {
    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE, "initRecovery:recoveryInitialized: " + recoveryInitialized);
    }

    if (recoveryInitialized) {
      // Only start initial recovery if it wasn't started before
      return;
    }

    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE, "initRecovery:properties: " + properties);
    }
    if (properties == null) {
      if (force) {
        _logger.log(Level.WARNING, "", new IllegalStateException());
      }
      return;
    }

    // Start if force is true or automatic-recovery is set
    String value = properties.getProperty(Configuration.MANUAL_RECOVERY);
    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE, "initRecovery:Configuration.MANUAL_RECOVERY: " + value);
    }
    if (force || (isValueSet(value) && "true".equals(value))) {
      recoveryInitialized = true;

      ServiceLocator serviceLocator = (ServiceLocator) properties.get(HABITAT);
      if (serviceLocator != null) {
        ProcessEnvironment processEnv = serviceLocator.getService(ProcessEnvironment.class);
        if (processEnv.getProcessType().isServer()) {
          // Start ResourceManager if it hadn't started yet
          serviceLocator.getAllServices(BuilderHelper.createNameFilter("ResourceManager"));
          value = properties.getProperty("pending-txn-cleanup-interval");
          int interval = -1;
          if (isValueSet(value)) {
            interval = Integer.parseInt(value);
          }
          new RecoveryHelperThread(serviceLocator, interval).start();
        }
        // Release all locks
        RecoveryManager.startResyncThread();
        if (_logger.isLoggable(Level.FINE)) _logger.log(Level.FINE, "[JTS] Started ResyncThread");
      }
    }
  }
Ejemplo n.º 2
0
  /**
   * Executes the command with the command parameters passed as Properties where the keys are the
   * parameter names and the values the parameter values
   *
   * @param context information
   */
  public void execute(AdminCommandContext context) {

    final ActionReport report = context.getActionReport();

    try {
      Collection<ManagedExecutorService> managedExecutorServices =
          domain.getResources().getResources(ManagedExecutorService.class);
      List<Map<String, String>> resourcesList = new ArrayList<Map<String, String>>();
      List<DefaultResourceProxy> drps = habitat.getAllServices(DefaultResourceProxy.class);

      for (ManagedExecutorService managedExecutorService : managedExecutorServices) {
        String jndiName = managedExecutorService.getJndiName();
        if (bindableResourcesHelper.resourceExists(jndiName, target)) {
          ActionReport.MessagePart part = report.getTopMessagePart().addChild();
          part.setMessage(jndiName);
          Map<String, String> resourceNameMap = new HashMap<String, String>();
          String logicalName = DefaultResourceProxy.Util.getLogicalName(drps, jndiName);
          if (logicalName != null) {
            resourceNameMap.put("logical-jndi-name", logicalName);
          }
          resourceNameMap.put("name", jndiName);
          resourcesList.add(resourceNameMap);
        }
      }

      Properties extraProperties = new Properties();
      extraProperties.put("managedExecutorServices", resourcesList);
      report.setExtraProperties(extraProperties);
    } catch (Exception e) {
      report.setMessage(
          localStrings.getLocalString(
              "list.managed.executor.service.failed", "List managed executor services failed"));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      report.setFailureCause(e);
      return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
  }