当前位置: 首页>>代码示例>>Java>>正文


Java Check.notNull方法代码示例

本文整理汇总了Java中org.apache.hadoop.lib.util.Check.notNull方法的典型用法代码示例。如果您正苦于以下问题:Java Check.notNull方法的具体用法?Java Check.notNull怎么用?Java Check.notNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.lib.util.Check的用法示例。


在下文中一共展示了Check.notNull方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setStatus

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Sets a new server status.
 * <p>
 * The status must be settable.
 * <p>
 * All services will be notified o the status change via the
 * {@link Service#serverStatusChange(Server.Status, Server.Status)} method. If a service
 * throws an exception during the notification, the server will be destroyed.
 *
 * @param status status to set.
 *
 * @throws ServerException thrown if the service has been destroy because of
 * a failed notification to a service.
 */
public void setStatus(Status status) throws ServerException {
  Check.notNull(status, "status");
  if (status.settable) {
    if (status != this.status) {
      Status oldStatus = this.status;
      this.status = status;
      for (Service service : services.values()) {
        try {
          service.serverStatusChange(oldStatus, status);
        } catch (Exception ex) {
          log.error("Service [{}] exception during status change to [{}] -server shutting down-,  {}",
                    new Object[]{service.getInterface().getSimpleName(), status, ex.getMessage(), ex});
          destroy();
          throw new ServerException(ServerException.ERROR.S11, service.getInterface().getSimpleName(),
                                    status, ex.getMessage(), ex);
        }
      }
    }
  } else {
    throw new IllegalArgumentException("Status [" + status + " is not settable");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:Server.java

示例2: setStatus

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Sets a new server status.
 * <p/>
 * The status must be settable.
 * <p/>
 * All services will be notified o the status change via the
 * {@link Service#serverStatusChange(Server.Status, Server.Status)} method. If a service
 * throws an exception during the notification, the server will be destroyed.
 *
 * @param status status to set.
 *
 * @throws ServerException thrown if the service has been destroy because of
 * a failed notification to a service.
 */
public void setStatus(Status status) throws ServerException {
  Check.notNull(status, "status");
  if (status.settable) {
    if (status != this.status) {
      Status oldStatus = this.status;
      this.status = status;
      for (Service service : services.values()) {
        try {
          service.serverStatusChange(oldStatus, status);
        } catch (Exception ex) {
          log.error("Service [{}] exception during status change to [{}] -server shutting down-,  {}",
                    new Object[]{service.getInterface().getSimpleName(), status, ex.getMessage(), ex});
          destroy();
          throw new ServerException(ServerException.ERROR.S11, service.getInterface().getSimpleName(),
                                    status, ex.getMessage(), ex);
        }
      }
    }
  } else {
    throw new IllegalArgumentException("Status [" + status + " is not settable");
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:37,代码来源:Server.java

示例3: schedule

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
@Override
public void schedule(final Callable<?> callable, long delay, long interval, TimeUnit unit) {
  Check.notNull(callable, "callable");
  if (!scheduler.isShutdown()) {
    LOG.debug("Scheduling callable [{}], interval [{}] seconds, delay [{}] in [{}]",
              new Object[]{callable, delay, interval, unit});
    Runnable r = new Runnable() {
      @Override
      public void run() {
        String instrName = callable.getClass().getSimpleName();
        Instrumentation instr = getServer().get(Instrumentation.class);
        if (getServer().getStatus() == Server.Status.HALTED) {
          LOG.debug("Skipping [{}], server status [{}]", callable, getServer().getStatus());
          instr.incr(INST_GROUP, instrName + ".skips", 1);
        } else {
          LOG.debug("Executing [{}]", callable);
          instr.incr(INST_GROUP, instrName + ".execs", 1);
          Instrumentation.Cron cron = instr.createCron().start();
          try {
            callable.call();
          } catch (Exception ex) {
            instr.incr(INST_GROUP, instrName + ".fails", 1);
            LOG.error("Error executing [{}], {}", new Object[]{callable, ex.getMessage(), ex});
          } finally {
            instr.addCron(INST_GROUP, instrName, cron.stop());
          }
        }
      }
    };
    scheduler.scheduleWithFixedDelay(r, delay, interval, unit);
  } else {
    throw new IllegalStateException(
      MessageFormat.format("Scheduler shutting down, ignoring scheduling of [{}]", callable));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:SchedulerService.java

示例4: schedule

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
@Override
public void schedule(final Callable<?> callable, long delay, long interval,
    TimeUnit unit) {
  Check.notNull(callable, "callable");
  if (!scheduler.isShutdown()) {
    LOG.debug(
        "Scheduling callable [{}], interval [{}] seconds, delay [{}] in [{}]",
        new Object[]{callable, delay, interval, unit});
    Runnable r = new Runnable() {
      @Override
      public void run() {
        String instrName = callable.getClass().getSimpleName();
        Instrumentation instr = getServer().get(Instrumentation.class);
        if (getServer().getStatus() == Server.Status.HALTED) {
          LOG.debug("Skipping [{}], server status [{}]", callable,
              getServer().getStatus());
          instr.incr(INST_GROUP, instrName + ".skips", 1);
        } else {
          LOG.debug("Executing [{}]", callable);
          instr.incr(INST_GROUP, instrName + ".execs", 1);
          Instrumentation.Cron cron = instr.createCron().start();
          try {
            callable.call();
          } catch (Exception ex) {
            instr.incr(INST_GROUP, instrName + ".fails", 1);
            LOG.error("Error executing [{}], {}",
                new Object[]{callable, ex.getMessage(), ex});
          } finally {
            instr.addCron(INST_GROUP, instrName, cron.stop());
          }
        }
      }
    };
    scheduler.scheduleWithFixedDelay(r, delay, interval, unit);
  } else {
    throw new IllegalStateException(MessageFormat
        .format("Scheduler shutting down, ignoring scheduling of [{}]",
            callable));
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:41,代码来源:SchedulerService.java

示例5: setStatus

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Sets a new server status.
 * <p/>
 * The status must be settable.
 * <p/>
 * All services will be notified o the status change via the
 * {@link Service#serverStatusChange(Server.Status, Server.Status)} method. If
 * a service
 * throws an exception during the notification, the server will be destroyed.
 *
 * @param status
 *     status to set.
 * @throws ServerException
 *     thrown if the service has been destroy because of
 *     a failed notification to a service.
 */
public void setStatus(Status status) throws ServerException {
  Check.notNull(status, "status");
  if (status.settable) {
    if (status != this.status) {
      Status oldStatus = this.status;
      this.status = status;
      for (Service service : services.values()) {
        try {
          service.serverStatusChange(oldStatus, status);
        } catch (Exception ex) {
          log.error(
              "Service [{}] exception during status change to [{}] -server shutting down-,  {}",
              new Object[]{service.getInterface().getSimpleName(), status,
                  ex.getMessage(), ex});
          destroy();
          throw new ServerException(ServerException.ERROR.S11,
              service.getInterface().getSimpleName(), status, ex.getMessage(),
              ex);
        }
      }
    }
  } else {
    throw new IllegalArgumentException(
        "Status [" + status + " is not settable");
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:43,代码来源:Server.java

示例6: get

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Returns the {@link Service} associated to the specified interface.
 *
 * @param serviceKlass service interface.
 *
 * @return the service implementation.
 */
@SuppressWarnings("unchecked")
public <T> T get(Class<T> serviceKlass) {
  ensureOperational();
  Check.notNull(serviceKlass, "serviceKlass");
  return (T) services.get(serviceKlass);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:Server.java

示例7: get

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Returns the {@link Service} associated to the specified interface.
 *
 * @param serviceKlass
 *     service interface.
 * @return the service implementation.
 */
@SuppressWarnings("unchecked")
public <T> T get(Class<T> serviceKlass) {
  ensureOperational();
  Check.notNull(serviceKlass, "serviceKlass");
  return (T) services.get(serviceKlass);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:14,代码来源:Server.java

示例8: RunnableCallable

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Constructor that takes a runnable.
 *
 * @param runnable runnable.
 */
public RunnableCallable(Runnable runnable) {
  this.runnable = Check.notNull(runnable, "runnable");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:RunnableCallable.java

示例9: XException

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Creates an XException using the specified error code. The exception
 * message is resolved using the error code template and the passed
 * parameters.
 *
 * @param error error code for the XException.
 * @param params parameters to use when creating the error message
 * with the error code template.
 */
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
public XException(ERROR error, Object... params) {
  this(Check.notNull(error, "error"), format(error, params), getCause(params));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:XException.java

示例10: RunnableCallable

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Constructor that takes a runnable.
 *
 * @param runnable
 *     runnable.
 */
public RunnableCallable(Runnable runnable) {
  this.runnable = Check.notNull(runnable, "runnable");
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:10,代码来源:RunnableCallable.java

示例11: XException

import org.apache.hadoop.lib.util.Check; //导入方法依赖的package包/类
/**
 * Creates an XException using the specified error code. The exception
 * message is resolved using the error code template and the passed
 * parameters.
 *
 * @param error
 *     error code for the XException.
 * @param params
 *     parameters to use when creating the error message
 *     with the error code template.
 */
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
public XException(ERROR error, Object... params) {
  this(Check.notNull(error, "error"), format(error, params),
      getCause(params));
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:17,代码来源:XException.java


注:本文中的org.apache.hadoop.lib.util.Check.notNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。