예제 #1
0
 @Override
 public void preLoadDPUs(List<DPUTemplateRecord> dpus) {
   for (DPUTemplateRecord dpu : dpus) {
     try {
       install(dpu);
     } catch (ModuleException e) {
       LOG.warn("Failed to pre-load dpu: {}", dpu.getJarPath(), e);
     }
   }
 }
예제 #2
0
 @Override
 public Dictionary<String, String> getJarProperties(DPUTemplateRecord dpu) {
   try {
     BundleContainer container = install(dpu);
     return container.getHeaders();
   } catch (ModuleException e) {
     LOG.error("Failed to install bundle: {}", dpu.getJarDirectory(), e);
   }
   return null;
 }
예제 #3
0
  @Override
  public void beginUpdate(DPUTemplateRecord dpu) {
    final String directory = dpu.getJarDirectory();
    // first we need lock on this directory
    lockUpdate(directory);
    // now we are the only one running .. we can work

    BundleContainer container = bundles.get(directory);
    if (container == null) {
      // bundle is not loaded .. create one, so we can lock it
      container = new BundleContainer(context, directory);
      bundles.put(directory, container);
    }

    // we secure that there exist record for DPU we wan't to load
  }
예제 #4
0
  @Override
  public void delete(DPUTemplateRecord dpu) {
    final String directory = dpu.getJarDirectory();
    lockUpdate(directory);
    // delete directory
    final File directoryFile = new File(getDPUDirectory(), directory);
    LOG.debug("Deleting {}", directory.toString());
    try {
      FileUtils.deleteDirectory(directoryFile);
    } catch (IOException e) {
      LOG.error("Failed to delete directory.", e);
    }
    // uninstall
    uninstall(directory);

    releaseUpdate(directory);
  }
예제 #5
0
  @Override
  public void endUpdate(DPUTemplateRecord dpu, boolean updateFailed) {
    final String directory = dpu.getJarDirectory();
    BundleContainer container = bundles.get(directory);
    if (container == null) {
      // bundle does not exist
    } else {
      // bundle exist
      if (updateFailed) {
        // we have to remove and uninstall the bundle
        try {
          container.uninstall();
        } catch (BundleException e) {
          LOG.error("Can't unistall bundle after update failure.", e);
        }
        // in every case remove from bundles
        bundles.remove(directory);
      }
    }

    // release lock for given directory
    releaseUpdate(directory);
  }
예제 #6
0
 /**
  * If container is not installed yet then install it. In every case return the installed instance
  * of {@link BundleContainer} for given directory. The container is installed as DPU container.
  *
  * @param dpu
  * @return
  * @throw ModuleException
  */
 private BundleContainer install(DPUTemplateRecord dpu) throws ModuleException {
   return install(dpu.getJarDirectory(), dpu.getJarName());
 }
예제 #7
0
 @Override
 public void unLoad(DPUTemplateRecord dpu) {
   final String directory = dpu.getJarDirectory();
   unLoad(directory);
 }