public void close() {
   cache.remove();
   rootObjectMapper.close();
   for (RootMapper rootMapper : rootMappersOrdered) {
     rootMapper.close();
   }
 }
Beispiel #2
0
 protected void setup(Slot s, Rendered r) {
   s.r = r;
   Slot pp = s.p = curp;
   if (pp == null) curref.set(this);
   try {
     curp = s;
     s.d = r.setup(this);
   } finally {
     if ((curp = pp) == null) curref.remove();
   }
 }
 @Override
 protected boolean access(long time) {
   boolean ret = super.access(time);
   firstAccess.remove();
   int ttl = getMaxInactiveInterval();
   expiryTime = ttl <= 0 ? 0 : time / 1000 + ttl;
   // prepare serialization
   redisMap.put("lastAccessed", "" + getLastAccessedTime());
   redisMap.put("accessed", "" + getAccessed());
   redisMap.put("expiryTime", "" + expiryTime);
   return ret;
 }
  /** Roll backs current transaction. */
  private void rollbackCurrentTx() {
    try {
      TxContext ctx = txCtx.get();

      if (ctx != null) {
        txCtx.remove();

        GridCacheTx tx = cache.tx();

        if (tx != null) tx.rollback();
      }
    } catch (GridException e) {
      log.error("Failed to rollback cache transaction.", e);
    }
  }
  /**
   * @param ctx Transaction context.
   * @param key Key.
   * @throws GridException If failed.
   */
  private void unlock(TxContext ctx, Object key) throws GridException {
    if (ctx.unlocked(key)) { // Finish transaction if last key is unlocked.
      txCtx.remove();

      GridCacheTx tx = cache.tx();

      assert tx != null;

      try {
        tx.commit();
      } finally {
        tx.close();
      }

      assert cache.tx() == null;
    }
  }
Beispiel #6
0
  public static Object runInTransaction(Callable fn) throws Exception {
    LockingTransaction t = transaction.get();
    Object ret;
    if (t == null) {
      transaction.set(t = new LockingTransaction());
      try {
        ret = t.run(fn);
      } finally {
        transaction.remove();
      }
    } else {
      if (t.info != null) {
        ret = fn.call();
      } else {
        ret = t.run(fn);
      }
    }

    return ret;
  }
  @SuppressWarnings({"rawtypes", "unchecked"})
  @Override
  public Object intercept(Invocation invocation) throws Throwable {
    final String name = invocation.getMethod().getName();
    final Object target = invocation.getTarget();
    if (target instanceof StatementHandler) {
      pagination(invocation, (StatementHandler) target);
    } else if (target instanceof Executor) {
      autoMap(invocation, name);
    } else if (target instanceof ResultSetHandler) {
      Object result = invocation.proceed();
      if (result instanceof List) {
        Page page = PAGE_THREAD_LOCAL.get();
        if (page != null) {
          page.addAll((List) result);
          PAGE_THREAD_LOCAL.remove();
          return page;
        }
      }
      return result;
    }

    return invocation.proceed();
  }
Beispiel #8
0
 @Override
 public void afterTransactionCompletion(org.hibernate.Transaction tx) {
   entities.remove();
 }
Beispiel #9
0
 private static void endTransaction() {
   _userAgent.remove();
 }
Beispiel #10
0
 public static void detachSession() {
   tss.remove();
 }
Beispiel #11
0
 /**
  * remove context.
  *
  * @see com.alibaba.dubbo.rpc.filter.ContextFilter
  */
 public static void removeContext() {
   LOCAL.remove();
 }
Beispiel #12
0
 private void checkClearTLs() {
   if (decRecurseDepth() == 0) {
     circDepTL.remove();
     recurseDepth.remove();
   }
 }
 public static void removeInstance() {
   instance.remove();
 }
Beispiel #14
0
 private void runAThread(ThreadedEntityProcessorWrapper epw, EntityRow rows, String currProcess)
     throws Exception {
   currentEntityProcWrapper.set(epw);
   epw.threadedInit(context);
   initEntity();
   try {
     epw.init(rows);
     DocWrapper docWrapper = this.docWrapper;
     Context.CURRENT_CONTEXT.set(context);
     for (; ; ) {
       if (DocBuilder.this.stop.get()) break;
       try {
         Map<String, Object> arow = epw.nextRow();
         if (arow == null) {
           break;
         } else {
           importStatistics.rowsCount.incrementAndGet();
           if (docWrapper == null && entity.isDocRoot) {
             docWrapper = new DocWrapper();
             context.setDoc(docWrapper);
             DataConfig.Entity e = entity.parentEntity;
             for (EntityRow row = rows;
                 row != null && e != null;
                 row = row.tail, e = e.parentEntity) {
               addFields(e, docWrapper, row.row, epw.resolver);
             }
           }
           if (docWrapper != null) {
             handleSpecialCommands(arow, docWrapper);
             addFields(entity, docWrapper, arow, epw.resolver);
           }
           if (entity.entities != null) {
             EntityRow nextRow = new EntityRow(arow, rows, entity.name);
             for (DataConfig.Entity e : entity.entities) {
               epw.children.get(e).run(docWrapper, currProcess, nextRow);
             }
           }
         }
         if (entity.isDocRoot) {
           LOG.info("a row on docroot" + docWrapper);
           if (!docWrapper.isEmpty()) {
             LOG.info("adding a doc " + docWrapper);
             boolean result = writer.upload(docWrapper);
             docWrapper = null;
             if (result) {
               importStatistics.docCount.incrementAndGet();
             } else {
               importStatistics.failedDocCount.incrementAndGet();
             }
           }
         }
       } catch (DataImportHandlerException dihe) {
         exception = dihe;
         if (dihe.getErrCode() == SKIP_ROW || dihe.getErrCode() == SKIP) {
           importStatistics.skipDocCount.getAndIncrement();
           exception = null; // should not propogate up
           continue;
         }
         if (entity.isDocRoot) {
           if (dihe.getErrCode() == DataImportHandlerException.SKIP) {
             importStatistics.skipDocCount.getAndIncrement();
             exception = null; // should not propogate up
           } else {
             LOG.error(
                 "Exception while processing: " + entity.name + " document : " + docWrapper,
                 dihe);
           }
           if (dihe.getErrCode() == DataImportHandlerException.SEVERE) throw dihe;
         } else {
           // if this is not the docRoot then the execution has happened in the same thread. so
           // propogate up,
           // it will be handled at the docroot
           entityEnded.set(true);
           throw dihe;
         }
         entityEnded.set(true);
       }
     }
   } finally {
     epw.destroy();
     currentEntityProcWrapper.remove();
     Context.CURRENT_CONTEXT.remove();
   }
 }