Esempio n. 1
0
 public void run() {
   try {
     RuntimeShell rshell = RuntimeShell.currentRuntimeShell();
     threads().addToContextLocals(SYSTEM_RUNTIME, "TimedEvent");
     SmartData data = (SmartData) rshell.lookupFor(objectflow, objectgroup, objectkey);
     assertion()
         .assertNotNull(
             data,
             "Cannot find data to post timed event to. "
                 + objectflow
                 + ":"
                 + objectgroup
                 + ":"
                 + objectkey
                 + ":"
                 + this.getClass().getClassLoader());
     Object evt = new TimedEvent("stateexpired", data);
     SmartEvent event = (SmartEvent) evt;
     // MessageConfig mc = new MessageConfig(event);
     CoreContext ctx = (CoreContext) anatomy().overriddenContext(this.getClass());
     MessageConfig mc = (MessageConfig) ctx.getMessageConfig(event);
     mc.postMessage();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.anon.smart.d2cache.store.StoreTransaction#commit()
   */
  @Override
  public void commit() throws CtxException {

    FileSystem hdfs = ((HadoopFileStoreConnection) _connection).getHadoopFS();

    assertion().assertNotNull(hdfs, "Hadoop FileSystem is null");

    String repo = hdfs.getWorkingDirectory().toUri().toString();

    for (Object fi : files.keySet()) {
      try {

        String[] params = (String[]) fi;

        Path destination = new Path(repo + "/" + params[1]);
        Path fldr = destination.getParent();
        if (!hdfs.exists(fldr)) hdfs.mkdirs(fldr);
        hdfs.copyFromLocalFile(true, new Path(params[0]), destination);

      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }