示例#1
0
 /**
  * Extract the set of version(s) of the given application represented as an untagged version name
  *
  * @param untaggedName the application name as an untagged version : an application name without
  *     version identifier
  * @param target the target where we want to get all the versions
  * @return all the version(s) of the given application
  */
 private final List<String> getAllversions(String untaggedName, String target) {
   List<Application> allApplications = null;
   if (target != null) {
     allApplications = domain.getApplicationsInTarget(target);
   } else {
     allApplications = domain.getApplications().getApplications();
   }
   return VersioningUtils.getVersions(untaggedName, allApplications);
 }
  private String getApplicationName(String path) {
    Habitat habitat = Globals.getDefaultHabitat();

    Domain domain = habitat.getInhabitantByType(Domain.class).get();

    List<Application> applicationList = domain.getApplications().getApplications();

    // looks like path always ends with "/" .. but just to be sure..
    for (Application app : applicationList) {
      if (path.startsWith(app.getContextRoot() + "/") || path.equals(app.getContextRoot()))
        return app.getName();
    }

    return null;
  }
  /**
   * Executes the command with the command parameters passed as Properties where the keys are the
   * paramter names and the values the parameter values
   *
   * @param context information
   */
  public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();

    HashMap attrList = new HashMap();
    setAttributeList(attrList);

    ResourceStatus rs;

    try {
      rs = managedExecutorServiceMgr.create(domain.getResources(), attrList, properties, target);
    } catch (Exception e) {
      report.setMessage(
          localStrings.getLocalString(
              "create.managed.executor.service.failed",
              "Managed executor service {0} creation failed",
              jndiName));
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      report.setFailureCause(e);
      return;
    }
    ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
    if (rs.getMessage() != null) {
      report.setMessage(rs.getMessage());
    }
    if (rs.getStatus() == ResourceStatus.FAILURE) {
      ec = ActionReport.ExitCode.FAILURE;
      if (rs.getException() != null) report.setFailureCause(rs.getException());
    }
    report.setActionExitCode(ec);
  }
 private void validateTarget(String target, String name) {
   List<String> referencedTargets = domain.getAllReferencedTargetsForApplication(name);
   if (referencedTargets.isEmpty()) {
     if (deployment.isRegistered(name)) {
       throw new IllegalArgumentException(
           localStrings.getLocalString(
               "lifecycle.use.create_app_ref_2",
               "Lifecycle module {0} is already created in this domain. Please use create application ref to create application reference on target {1}",
               name,
               target));
     }
   } else {
     if (referencedTargets.contains(target)) {
       throw new IllegalArgumentException(
           localStrings.getLocalString(
               "lifecycle.alreadyreg",
               "Lifecycle module {0} is already created on this target {1}",
               name,
               target));
     } else {
       throw new IllegalArgumentException(
           localStrings.getLocalString(
               "lifecycle.use.create_app_ref",
               "Lifecycle module {0} is already referenced by other target(s). Please use create application ref to create application reference on target {1}",
               name,
               target));
     }
   }
 }
示例#5
0
  /**
   * Search the enabled versions on the referenced targets of the given version. This method is
   * designed to be used with domain target. As different versions maybe enabled on different
   * targets, the return type used is a map.
   *
   * @param versionIdentifier a version expression (that contains wildcard character)
   * @return a map matching the enabled versions with their target(s)
   * @throws VersioningSyntaxException if getEnabledVersion throws an exception
   */
  public Map<String, Set<String>> getEnabledVersionsInReferencedTargets(String versionIdentifier)
      throws VersioningSyntaxException {

    Map<String, Set<String>> enabledVersionsInTargets = new HashMap<String, Set<String>>();

    List<String> allTargets = domain.getAllReferencedTargetsForApplication(versionIdentifier);

    Iterator it = allTargets.iterator();
    while (it.hasNext()) {
      String target = (String) it.next();
      String enabledVersion = getEnabledVersion(versionIdentifier, target);
      if (enabledVersion != null) {
        // the key already exists, we just add the new target into the list
        if (enabledVersionsInTargets.containsKey(enabledVersion)) {
          enabledVersionsInTargets.get(enabledVersion).add(target);
        } else {
          // we have to create the list associated with the key
          Set<String> setTargets = new HashSet<String>();
          setTargets.add(target);
          enabledVersionsInTargets.put(enabledVersion, setTargets);
        }
      }
    }
    return enabledVersionsInTargets;
  }
  private void updateLoadBalancerElements() {
    LoadBalancers loadBalancers = domain.getLoadBalancers();
    List<LoadBalancer> loadBalancerList = loadBalancers.getLoadBalancer();

    for (LoadBalancer loadBalancer : loadBalancerList) {
      try {
        ConfigSupport.apply(new LoadBalancerConfigCode(), loadBalancer);
      } catch (TransactionFailure ex) {
        String msg =
            LbLogUtil.getStringManager()
                .getString("ErrorDuringUpgrade", loadBalancer.getName(), ex.getMessage());
        Logger.getAnonymousLogger().log(Level.SEVERE, msg);
        if (Logger.getAnonymousLogger().isLoggable(Level.FINE)) {
          Logger.getAnonymousLogger().log(Level.FINE, "Exception during upgrade operation", ex);
        }
      }
    }
  }
  private void handlePoolRecreationForExistingProxies(ConnectorConnectionPool connConnPool) {

    recreatePool(connConnPool);

    Collection<BindableResource> resourcesList;
    if (!connConnPool.isApplicationScopedResource()) {
      resourcesList =
          JdbcResourcesUtil.getResourcesOfPool(domain.getResources(), connConnPool.getName());
    } else {
      PoolInfo poolInfo = connConnPool.getPoolInfo();
      Resources resources = ResourcesUtil.createInstance().getResources(poolInfo);
      resourcesList = JdbcResourcesUtil.getResourcesOfPool(resources, connConnPool.getName());
    }
    for (BindableResource bindableResource : resourcesList) {

      ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(bindableResource);
      ConnectorRegistry.getInstance().updateResourceInfoVersion(resourceInfo);
    }
  }
示例#8
0
  /**
   * Search for the enabled version of the given application.
   *
   * @param name the application name
   * @param target an option supply from admin command, it's retained for compatibility with other
   *     releases
   * @return the enabled version of the application, if exists
   * @throws VersioningSyntaxException if getUntaggedName throws an exception
   */
  public final String getEnabledVersion(String name, String target)
      throws VersioningSyntaxException {

    String untaggedName = VersioningUtils.getUntaggedName(name);
    List<String> allVersions = getAllversions(untaggedName, target);

    if (allVersions != null) {
      Iterator it = allVersions.iterator();

      while (it.hasNext()) {
        String app = (String) it.next();

        // if a version of the app is enabled
        if (domain.isAppEnabledInTarget(app, target)) {
          return app;
        }
      }
    }
    // no enabled version found
    return null;
  }
  /**
   * 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);
  }
示例#10
0
  /**
   * Get the version directory-deployed from the given directory
   *
   * @param directory
   * @return the name of the version currently using the directory, else null
   * @throws VersioningSyntaxException *
   */
  public String getVersionFromSameDir(File dir) throws VersioningSyntaxException {

    try {
      Iterator it = domain.getApplications().getApplications().iterator();
      Application app = null;

      // check if directory deployment exist
      while (it.hasNext()) {
        app = (Application) it.next();
        /*
         * A lifecycle module appears as an application but has a null location.
         */
        if (dir.toURI().toString().equals(app.getLocation())) {
          if (!VersioningUtils.getUntaggedName(app.getName()).equals(app.getName())) {
            return app.getName();
          }
        }
      }
    } catch (VersioningSyntaxException ex) {
      // return null if an exception is thrown
    }
    return null;
  }
示例#11
0
  public void execute(AdminCommandContext context) {

    final ActionReport report = context.getActionReport();

    Properties props = initFileXferProps();

    Server targetServer = domain.getServerNamed(target);

    if (targetServer != null && targetServer.isDas()) {

      // This loop if target instance is DAS
      String logFileDetails = "";
      String zipFile = "";

      try {
        // getting log file values from logging.propertie file.
        logFileDetails = loggingConfig.getLoggingFileDetails();
      } catch (Exception ex) {
        final String errorMsg =
            localStrings.getLocalString(
                "collectlogfiles.errGettingLogFiles",
                "Error while getting log file attribute for {0}.",
                target);
        report.setMessage(errorMsg);
        report.setFailureCause(ex);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }

      File targetDir = makingDirectoryOnDas(targetServer.getName(), report);

      try {

        String sourceDir = "";
        if (logFileDetails.contains("${com.sun.aas.instanceRoot}/logs")) {
          sourceDir = env.getDomainRoot() + File.separator + "logs";
        } else {
          sourceDir = logFileDetails.substring(0, logFileDetails.lastIndexOf(File.separator));
        }

        copyLogFilesForLocalhost(
            sourceDir, targetDir.getAbsolutePath(), report, targetServer.getName());
      } catch (Exception ex) {
        final String errorMsg =
            localStrings.getLocalString(
                "collectlogfiles.errInstanceDownloading",
                "Error while downloading log files from {0}.",
                target);
        report.setMessage(errorMsg);
        report.setFailureCause(ex);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }

      try {
        String zipFilePath = getZipFilePath().getAbsolutePath();
        zipFile = loggingConfig.createZipFile(zipFilePath);
        if (zipFile == null || new File(zipFile) == null) {
          // Failure during zip
          final String errorMsg =
              localStrings.getLocalString(
                  "collectlogfiles.creatingZip", "Error while creating zip file {0}.", zipFilePath);
          report.setMessage(errorMsg);
          report.setActionExitCode(ActionReport.ExitCode.FAILURE);
          return;
        }

      } catch (Exception e) {
        // Catching Exception if any
        final String errorMsg =
            localStrings.getLocalString(
                "collectlogfiles.creatingZip", "Error while creating zip file {0}.", zipFile);
        report.setMessage(errorMsg);
        report.setFailureCause(e);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }

      if (this.retrieve) {
        retrieveFile(zipFile, context, getZipFilePath(), props, report);
        report.setMessage(
            localStrings.getLocalString(
                "collectlogfiles.instance.success",
                "Created Zip file under {0}.",
                retrieveFilePath + File.separator + new File(zipFile).getName()));
      } else {
        report.setMessage(
            localStrings.getLocalString(
                "collectlogfiles.instance.success", "Created Zip file under {0}.", zipFile));
      }

    } else if (targetServer != null && targetServer.isInstance()) {

      // This loop if target standalone instance
      String instanceName = targetServer.getName();
      String serverNode = targetServer.getNodeRef();
      Node node = domain.getNodes().getNode(serverNode);
      String zipFile = "";
      File targetDir = null;

      String logFileDetails = "";
      try {
        // getting log file values from logging.propertie file.
        logFileDetails = getInstanceLogFileDirectory(targetServer);
      } catch (Exception ex) {
        final String errorMsg =
            localStrings.getLocalString(
                "collectlogfiles.errGettingLogFiles",
                "Error while getting log file attribute for {0}.",
                target);
        report.setMessage(errorMsg);
        report.setFailureCause(ex);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }

      targetDir = makingDirectoryOnDas(targetServer.getName(), report);

      try {
        if (node.isLocal()) {
          String sourceDir = getLogDirForLocalNode(logFileDetails, node, serverNode, instanceName);
          copyLogFilesForLocalhost(sourceDir, targetDir.getAbsolutePath(), report, instanceName);
        } else {
          new LogFilterForInstance()
              .downloadAllInstanceLogFiles(
                  habitat,
                  targetServer,
                  domain,
                  LOGGER,
                  instanceName,
                  targetDir.getAbsolutePath(),
                  logFileDetails);
        }
      } catch (Exception ex) {
        final String errorMsg =
            localStrings.getLocalString(
                "collectlogfiles.errInstanceDownloading",
                "Error while downloading log files from {0}.",
                instanceName);
        report.setMessage(errorMsg);
        report.setFailureCause(ex);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }

      try {
        // Creating zip file and returning zip file absolute path.
        String zipFilePath = getZipFilePath().getAbsolutePath();
        zipFile = loggingConfig.createZipFile(zipFilePath);
        if (zipFile == null || new File(zipFile) == null) {
          // Failure during zip
          final String errorMsg =
              localStrings.getLocalString(
                  "collectlogfiles.creatingZip", "Error while creating zip file {0}.", zipFilePath);
          report.setMessage(errorMsg);
          report.setActionExitCode(ActionReport.ExitCode.FAILURE);
          return;
        }
      } catch (Exception ex) {
        final String errorMsg =
            localStrings.getLocalString(
                "collectlogfiles.creatingZip", "Error while creating zip file {0}.", zipFile);
        report.setMessage(errorMsg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }

      if (this.retrieve) {
        retrieveFile(zipFile, context, getZipFilePath(), props, report);
        report.setMessage(
            localStrings.getLocalString(
                "collectlogfiles.instance.success",
                "Created Zip file under {0}.",
                retrieveFilePath + File.separator + new File(zipFile).getName()));
      } else {
        report.setMessage(
            localStrings.getLocalString(
                "collectlogfiles.instance.success", "Created Zip file under {0}.", zipFile));
      }

    } else {
      // This loop if target is cluster

      String finalMessage = "";
      String zipFile = "";
      File targetDir = null;

      // code to download server.log file for DAS. Bug fix 16088
      String logFileDetails = "";
      try {
        // getting log file values from logging.propertie file.
        logFileDetails = loggingConfig.getLoggingFileDetails();
      } catch (Exception ex) {
        final String errorMsg =
            localStrings.getLocalString(
                "collectlogfiles.errGettingLogFiles",
                "Error while getting log file attribute for {0}.",
                target);
        report.setMessage(errorMsg);
        report.setFailureCause(ex);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }

      targetDir =
          makingDirectoryOnDas(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME, report);

      try {
        String sourceDir = "";
        if (logFileDetails.contains("${com.sun.aas.instanceRoot}/logs")) {
          sourceDir = env.getDomainRoot() + File.separator + "logs";
        } else {
          sourceDir = logFileDetails.substring(0, logFileDetails.lastIndexOf(File.separator));
        }

        copyLogFilesForLocalhost(
            sourceDir,
            targetDir.getAbsolutePath(),
            report,
            SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME);
      } catch (Exception ex) {
        final String errorMsg =
            localStrings.getLocalString(
                "collectlogfiles.errInstanceDownloading",
                "Error while downloading log files from {0}.",
                target);
        report.setMessage(errorMsg);
        report.setFailureCause(ex);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
      }
      /** *************************************************** */
      com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);

      List<Server> instances = cluster.getInstances();

      int instanceCount = 0;
      int errorCount = 0;
      for (Server instance : instances) {
        // downloading log files for all instances which is part of cluster under temp directory.
        String instanceName = instance.getName();
        String serverNode = instance.getNodeRef();
        Node node = domain.getNodes().getNode(serverNode);
        boolean errorOccur = false;
        instanceCount++;

        logFileDetails = "";
        try {
          // getting log file values from logging.propertie file.
          logFileDetails = getInstanceLogFileDirectory(domain.getServerNamed(instanceName));
        } catch (Exception ex) {
          final String errorMsg =
              localStrings.getLocalString(
                  "collectlogfiles.errGettingLogFiles",
                  "Error while getting log file attribute for {0}.",
                  target);
          report.setMessage(errorMsg);
          report.setFailureCause(ex);
          report.setActionExitCode(ActionReport.ExitCode.FAILURE);
          return;
        }

        try {
          targetDir = makingDirectoryOnDas(instanceName, report);

          if (node.isLocal()) {
            String sourceDir =
                getLogDirForLocalNode(logFileDetails, node, serverNode, instanceName);
            copyLogFilesForLocalhost(sourceDir, targetDir.getAbsolutePath(), report, instanceName);
          } else {
            new LogFilterForInstance()
                .downloadAllInstanceLogFiles(
                    habitat,
                    instance,
                    domain,
                    LOGGER,
                    instanceName,
                    targetDir.getAbsolutePath(),
                    logFileDetails);
          }
        } catch (Exception ex) {
          errorCount++;
          final String errorMsg =
              localStrings.getLocalString(
                  "collectlogfiles.errInstanceDownloading",
                  "Error while downloading log files from {0}.",
                  instanceName);
          errorOccur = true;
          finalMessage += errorMsg + "\n";
        }
        if (!errorOccur) {
          final String successMsg =
              localStrings.getLocalString(
                  "collectlogfiles.successInstanceDownloading",
                  "Log files are downloaded for {0}.",
                  instanceName);
          finalMessage += successMsg + "\n";
        }
      }
      report.setMessage(finalMessage);

      if (instanceCount != errorCount) {
        try {
          String zipFilePath = getZipFilePath().getAbsolutePath();
          // Creating zip file and returning zip file absolute path.
          zipFile = loggingConfig.createZipFile(zipFilePath);
          if (zipFile == null || new File(zipFile) == null) {
            // Failure during zip
            final String errorMsg =
                localStrings.getLocalString(
                    "collectlogfiles.creatingZip",
                    "Error while creating zip file {0}.",
                    zipFilePath);
            report.setMessage(errorMsg);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
          }
        } catch (Exception ex) {
          final String errorMsg =
              localStrings.getLocalString(
                  "collectlogfiles.creatingZip", "Error while creating zip file {0}.", zipFile);
          report.setMessage(errorMsg);
          report.setFailureCause(ex);
          report.setActionExitCode(ActionReport.ExitCode.FAILURE);
          return;
        }

        if (this.retrieve) {
          retrieveFile(zipFile, context, getZipFilePath(), props, report);
          report.setMessage(
              localStrings.getLocalString(
                  "collectlogfiles.cluster.success",
                  "{0} Created Zip file under {1}.",
                  finalMessage,
                  retrieveFilePath + File.separator + new File(zipFile).getName()));
        } else {
          report.setMessage(
              localStrings.getLocalString(
                  "collectlogfiles.cluster.success",
                  "{0} Created Zip file under {1}.",
                  finalMessage,
                  zipFile));
        }

        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
      } else if (instanceCount == 0) {
        report.setMessage(
            localStrings.getLocalString(
                "collectlogfiles.noinstance",
                "No instances are defined as part of {0}. So there are no files to zip.",
                target));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      } else {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      }
    }

    deleteDir(
        new File(
            env.getInstanceRoot() + File.separator + "collected-logs" + File.separator + "logs"));
  }
  public static synchronized Properties getJTSProperties(
      ServiceLocator serviceLocator, boolean isORBAvailable) {
    if (orbAvailable == isORBAvailable && properties != null) {
      // We will need to update the properties if ORB availability changed
      return properties;
    }

    Properties jtsProperties = new Properties();
    if (serviceLocator != null) {
      jtsProperties.put(HABITAT, serviceLocator);
      ProcessEnvironment processEnv = serviceLocator.getService(ProcessEnvironment.class);
      if (processEnv.getProcessType().isServer()) {
        TransactionService txnService =
            serviceLocator.getService(
                TransactionService.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);

        if (txnService != null) {
          jtsProperties.put(Configuration.HEURISTIC_DIRECTION, txnService.getHeuristicDecision());
          jtsProperties.put(Configuration.KEYPOINT_COUNT, txnService.getKeypointInterval());

          String automaticRecovery = txnService.getAutomaticRecovery();
          boolean isAutomaticRecovery =
              (isValueSet(automaticRecovery) && "true".equals(automaticRecovery));
          if (isAutomaticRecovery) {
            _logger.log(Level.FINE, "Recoverable J2EE Server");
            jtsProperties.put(Configuration.MANUAL_RECOVERY, "true");
          }

          boolean disable_distributed_transaction_logging = false;
          String dbLoggingResource = null;
          for (Property prop : txnService.getProperty()) {
            String name = prop.getName();
            String value = prop.getValue();

            if (name.equals("disable-distributed-transaction-logging")) {
              if (isValueSet(value) && "true".equals(value)) {
                disable_distributed_transaction_logging = true;
              }

            } else if (name.equals("xaresource-txn-timeout")) {
              if (isValueSet(value)) {
                _logger.log(Level.FINE, "XAResource transaction timeout is" + value);
                TransactionManagerImpl.setXAResourceTimeOut(Integer.parseInt(value));
              }

            } else if (name.equals("db-logging-resource")) {
              dbLoggingResource = value;
              _logger.log(Level.FINE, "Transaction DB Logging Resource Name" + dbLoggingResource);
              if (dbLoggingResource != null
                  && (" ".equals(dbLoggingResource) || "".equals(dbLoggingResource))) {
                dbLoggingResource = "jdbc/TxnDS";
              }

            } else if (name.equals("xa-servername")) {
              if (isValueSet(value)) {
                jtsProperties.put(JTS_XA_SERVER_NAME, value);
              }

            } else if (name.equals("pending-txn-cleanup-interval")) {
              if (isValueSet(value)) {
                jtsProperties.put("pending-txn-cleanup-interval", value);
              }

            } else if (name.equals(Configuration.COMMIT_ONE_PHASE_DURING_RECOVERY)) {
              if (isValueSet(value)) {
                jtsProperties.put(Configuration.COMMIT_ONE_PHASE_DURING_RECOVERY, value);
              }
            } else if (name.equals("add-wait-point-during-recovery")) {
              if (isValueSet(value)) {
                try {
                  FailureInducer.setWaitPointRecovery(Integer.parseInt(value));
                } catch (Exception e) {
                  _logger.log(Level.WARNING, e.getMessage());
                }
              }
            }
          }

          if (dbLoggingResource != null) {
            disable_distributed_transaction_logging = true;
            jtsProperties.put(Configuration.DB_LOG_RESOURCE, dbLoggingResource);
          }

          /**
           * JTS_SERVER_ID needs to be unique for each for server instance. This will be used as
           * recovery identifier along with the hostname for example: if the hostname is 'tulsa' and
           * iiop-listener-port is 3700 recovery identifier will be tulsa,P3700
           */
          int jtsServerId = DEFAULT_SERVER_ID; // default value

          if (isORBAvailable) {
            jtsServerId =
                serviceLocator
                    .<GlassFishORBHelper>getService(GlassFishORBHelper.class)
                    .getORBInitialPort();
            if (jtsServerId == 0) {
              // XXX Can this ever happen?
              jtsServerId = DEFAULT_SERVER_ID; // default value
            }
          }
          jtsProperties.put(JTS_SERVER_ID, String.valueOf(jtsServerId));

          /* ServerId is an J2SE persistent server activation
            API.  ServerId is scoped at the ORBD.  Since
            There is no ORBD present in J2EE the value of
            ServerId is meaningless - except it must have
            SOME value if persistent POAs are created.
          */

          // For clusters - all servers in the cluster MUST
          // have the same ServerId so when failover happens
          // and requests are delivered to a new server, the
          // ServerId in the request will match the new server.

          String serverId = String.valueOf(DEFAULT_SERVER_ID);
          System.setProperty(J2EE_SERVER_ID_PROP, serverId);

          ServerContext ctx = serviceLocator.getService(ServerContext.class);
          String instanceName = ctx.getInstanceName();

          /**
           * if the auto recovery is true, always transaction logs will be written irrespective of
           * disable_distributed_transaction_logging. if the auto recovery is false, then
           * disable_distributed_transaction_logging will be used to write transaction logs are
           * not.If disable_distributed_transaction_logging is set to false(by default false) logs
           * will be written, set to true logs won't be written.
           */
          if (!isAutomaticRecovery && disable_distributed_transaction_logging) {
            Configuration.disableFileLogging();
          } else {

            // if (dbLoggingResource == null) {
            Domain domain = serviceLocator.getService(Domain.class);
            Server server = domain.getServerNamed(instanceName);

            // Check if the server system property is set
            String logdir = getTXLogDir(server);

            // if not, check if the cluster system property is set
            if (logdir == null) {
              Cluster cluster = server.getCluster();
              if (cluster != null) {
                logdir = getTXLogDir(cluster);
              }
            }

            // No system properties are set - get tx log dir from transaction service
            if (logdir == null) {
              logdir = txnService.getTxLogDir();
            }

            if (logdir == null) {
              logdir = domain.getLogRoot();
              if (logdir == null) {
                // logdir = FileUtil.getAbsolutePath(".." + File.separator + "logs");
                logdir = ".." + File.separator + "logs";
              }
            } else if (!(new File(logdir)).isAbsolute()) {
              if (_logger.isLoggable(Level.FINE)) {
                _logger.log(
                    Level.FINE,
                    "Relative pathname specified for transaction log directory : " + logdir);
              }
              String logroot = domain.getLogRoot();
              if (logroot != null) {
                logdir = logroot + File.separator + logdir;
              } else {
                // logdir = FileUtil.getAbsolutePath(".." + File.separator + "logs"
                // + File.separator + logdir);
                logdir = ".." + File.separator + "logs" + File.separator + logdir;
              }
            }
            logdir += File.separator + instanceName + File.separator + "tx";

            if (_logger.isLoggable(Level.FINE)) {
              _logger.log(Level.FINE, "JTS log directory: " + logdir);
              _logger.log(Level.FINE, "JTS Server id " + jtsServerId);
            }

            jtsProperties.put(Configuration.LOG_DIRECTORY, logdir);
          }
          jtsProperties.put(Configuration.COMMIT_RETRY, txnService.getRetryTimeoutInSeconds());
          jtsProperties.put(Configuration.INSTANCE_NAME, instanceName);
        }
      }
    }

    properties = jtsProperties;
    orbAvailable = isORBAvailable;

    return properties;
  }