예제 #1
0
  /**
   * Process a distribution root.
   *
   * @param parent the misc root
   * @param distributionRoot the distribution root
   * @param distribution the distribution
   * @throws IOException
   */
  static void process(
      final DistributionContentItem parent, final File distributionRoot, Distribution distribution)
      throws IOException {
    final DistributionProcessor processor = new DistributionProcessor();
    final File[] children = distributionRoot.listFiles();
    if (children != null && children.length != 0) {
      for (final File child : children) {
        processor.processMisc(parent, child, distribution);
      }
    }

    final List<File> mp = new ArrayList<File>();
    final Set<DistributionContentItem> moduleRoots = processor.moduleRoots;
    for (final DistributionContentItem item : moduleRoots) {
      final File file = item.getFile(distributionRoot);
      mp.add(file);
    }

    // Update name and version
    final ModuleLoader loader = new LocalModuleLoader(mp.toArray(new File[mp.size()]));
    final ProductConfig config =
        new ProductConfig(loader, distributionRoot.getAbsolutePath(), Collections.emptyMap());
    distribution.setName(config.resolveName());
    distribution.setVersion(config.resolveVersion());
  }
예제 #2
0
  private File createNextCumulativePatchAddingRandomModule(
      String patchID,
      String asVersion,
      final String currentPatch,
      final String targetAsVersion,
      File targetDir)
      throws Exception {
    String layerPatchID = "layer" + patchID;
    File cpPatchDir = mkdir(tempDir, patchID);
    final String moduleName = "org.wildfly.test." + randomString();

    // Create the version module
    final String versionModuleName = ProductInfo.getVersionModule();
    final Module modifiedModule = PatchingTestUtil.createVersionModule(targetAsVersion);

    // Calculate the target hash of the currently active module
    final String currentLayerPatchID = "layer" + currentPatch;
    File originalVersionModulePath = new File(tempDir, currentPatch);
    originalVersionModulePath = new File(originalVersionModulePath, currentLayerPatchID);
    originalVersionModulePath = new File(originalVersionModulePath, Constants.MODULES);
    originalVersionModulePath = newFile(originalVersionModulePath, versionModuleName.split("\\."));
    originalVersionModulePath =
        new File(originalVersionModulePath, ProductInfo.getVersionModuleSlot());
    byte[] patchedAsVersionHash = HashUtils.hashFile(originalVersionModulePath);
    assert patchedAsVersionHash != null;

    final ResourceItem resourceItem1 = new ResourceItem("testFile1", "content1".getBytes());
    final ResourceItem resourceItem2 = new ResourceItem("testFile2", "content2".getBytes());

    Module newModule =
        new Module.Builder(moduleName).miscFile(resourceItem1).miscFile(resourceItem2).build();

    ContentModification moduleAdded =
        ContentModificationUtils.addModule(cpPatchDir, layerPatchID, newModule);
    ContentModification versionModuleModified =
        ContentModificationUtils.modifyModule(
            cpPatchDir, layerPatchID, patchedAsVersionHash, modifiedModule);

    ProductConfig productConfig = new ProductConfig(PRODUCT, asVersion, "main");
    Patch cpPatch =
        PatchBuilder.create()
            .setPatchId(patchID)
            .setDescription("A cp patch.")
            .upgradeIdentity(
                productConfig.getProductName(), productConfig.getProductVersion(), targetAsVersion)
            .getParent()
            .upgradeElement(layerPatchID, "base", false)
            .addContentModification(versionModuleModified)
            .addContentModification(moduleAdded)
            .getParent()
            .build();
    createPatchXMLFile(cpPatchDir, cpPatch);
    return createZippedPatchFile(cpPatchDir, patchID, targetDir);
  }
예제 #3
0
 private File createOneOffPatchAddingMiscFile(String patchID, String asVersion) throws Exception {
   File oneOffPatchDir = mkdir(tempDir, patchID);
   ContentModification miscFileAdded =
       ContentModificationUtils.addMisc(
           oneOffPatchDir, patchID, "test content", "awesomeDirectory", "awesomeFile");
   ProductConfig productConfig = new ProductConfig(PRODUCT, asVersion, "main");
   Patch oneOffPatch =
       PatchBuilder.create()
           .setPatchId(patchID)
           .setDescription("A one-off patch adding a misc file.")
           .oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion())
           .getParent()
           .addContentModification(miscFileAdded)
           .build();
   createPatchXMLFile(oneOffPatchDir, oneOffPatch);
   return createZippedPatchFile(oneOffPatchDir, patchID);
 }
  @Override
  public void start(StartContext context) throws StartException {

    processState.setStarting();

    final ProductConfig config = environment.getProductConfig();
    final String prettyVersion = config.getPrettyVersionString();
    ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion);
    if (ServerLogger.CONFIG_LOGGER.isDebugEnabled()) {
      final Properties properties = System.getProperties();
      final StringBuilder b = new StringBuilder(8192);
      b.append("Configured system properties:");
      for (String property : new TreeSet<String>(properties.stringPropertyNames())) {
        b.append("\n\t")
            .append(property)
            .append(" = ")
            .append(properties.getProperty(property, "<undefined>"));
      }
      ServerLogger.CONFIG_LOGGER.debug(b);
      ServerLogger.CONFIG_LOGGER.debugf("VM Arguments: %s", getVMArguments());
      if (ServerLogger.CONFIG_LOGGER.isTraceEnabled()) {
        b.setLength(0);
        final Map<String, String> env = System.getenv();
        b.append("Configured system environment:");
        for (String key : new TreeSet<String>(env.keySet())) {
          b.append("\n\t").append(key).append(" = ").append(env.get(key));
        }
        ServerLogger.CONFIG_LOGGER.trace(b);
      }
    }
    final ServiceTarget serviceTarget = context.getChildTarget();
    final ServiceController<?> myController = context.getController();
    final ServiceContainer serviceContainer = myController.getServiceContainer();
    futureContainer = new FutureServiceContainer();

    long startTime = this.startTime;
    if (startTime == -1) {
      startTime = System.currentTimeMillis();
    } else {
      this.startTime = -1;
    }

    final BootstrapListener bootstrapListener =
        new BootstrapListener(
            serviceContainer,
            startTime,
            serviceTarget,
            futureContainer,
            prettyVersion + " (Host Controller)");
    bootstrapListener.getStabilityMonitor().addController(myController);

    // The first default services are registered before the bootstrap operations are executed.

    // Install the process controller client
    final ProcessControllerConnectionService processControllerClient =
        new ProcessControllerConnectionService(environment, authCode);
    serviceTarget
        .addService(ProcessControllerConnectionService.SERVICE_NAME, processControllerClient)
        .install();

    // Executor Services
    final HostControllerExecutorService executorService = new HostControllerExecutorService();
    serviceTarget
        .addService(HC_EXECUTOR_SERVICE_NAME, executorService)
        .addAliases(
            ManagementRemotingServices
                .SHUTDOWN_EXECUTOR_NAME) // Use this executor for mgmt shutdown for now
        .install();

    // Install required path services. (Only install those identified as required)
    HostPathManagerService hostPathManagerService = new HostPathManagerService();
    HostPathManagerService.addService(serviceTarget, hostPathManagerService, environment);

    HttpListenerRegistryService.install(serviceTarget);

    // Add product config service
    final Value<ProductConfig> productConfigValue = new ImmediateValue<ProductConfig>(config);
    serviceTarget
        .addService(
            Services.JBOSS_PRODUCT_CONFIG_SERVICE,
            new ValueService<ProductConfig>(productConfigValue))
        .setInitialMode(ServiceController.Mode.ACTIVE)
        .install();

    DomainModelControllerService.addService(
        serviceTarget,
        environment,
        runningModeControl,
        processState,
        bootstrapListener,
        hostPathManagerService);
  }