• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ArgumentVerifier类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.threadly.util.ArgumentVerifier的典型用法代码示例。如果您正苦于以下问题:Java ArgumentVerifier类的具体用法?Java ArgumentVerifier怎么用?Java ArgumentVerifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ArgumentVerifier类属于org.threadly.util包,在下文中一共展示了ArgumentVerifier类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: HprofParser

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
/**
 * Constructs a new parser for a given file.
 * 
 * @param executor Executor that computation can be threaded out to
 * @param hprofFile File that should be parsed
 */
public HprofParser(SubmitterExecutorInterface executor, File hprofFile) {
  ArgumentVerifier.assertNotNull(hprofFile, "hprofFile");
  if (! hprofFile.exists()) {
    throw new IllegalArgumentException("File does not exist: " + hprofFile);
  } else if (! hprofFile.canRead()) {
    throw new IllegalArgumentException("Can not read file: " + hprofFile);
  }
  if (VERBOSE) {  // use single thread in verbose so the out makes sense
    this.executor = SameThreadSubmitterExecutor.instance();
  } else {
    this.executor = executor;
  }
  this.hprofFile = hprofFile;
  parsingFutures = Collections.synchronizedList(new ArrayList<ListenableFuture<?>>());
  classMap = Collections.synchronizedMap(new HashMap<Long, ClassDefinition>());
  instances = Collections.synchronizedMap(new HashMap<Long, Instance>());
  stringMap = new HashMap<>();
  instanceSummary = new HashMap<>();
  arraySummary = new HashMap<>();
  leafInstances = new ArrayList<>();
}
 
开发者ID:threadly,项目名称:heapDumpAnalyzer,代码行数:28,代码来源:HprofParser.java


示例2: pullBuffer

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public ByteBuffer pullBuffer(int size) {
  ArgumentVerifier.assertNotNegative(size, "size");
  if (size == 0) {
    return IOUtils.EMPTY_BYTEBUFFER;
  }
  if (remaining() < size) {
    throw new BufferUnderflowException();
  }
  consumedSize += size;
  final ByteBuffer first = getNextBuffer();
  if(first.remaining() == size) {
    currentBuffer++;
    return first.slice();
  } else if(first.remaining() > size) {
    final ByteBuffer bb = first.duplicate().slice();
    bb.limit(bb.position()+size);
    first.position(first.position()+size);
    return bb;
  } else {
    final byte[] result = new byte[size];
    doGet(result);
    return ByteBuffer.wrap(result);
  }
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:26,代码来源:SimpleMergedByteBuffers.java


示例3: discard

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public void discard(int size) {
  ArgumentVerifier.assertNotNegative(size, "size");
  if (remaining() < size) {
    throw new BufferUnderflowException();
  }
  //We have logic here since we dont need to do any copying and we just drop the bytes
  int toRemoveAmount = size;
  while (toRemoveAmount > 0) {
    final ByteBuffer buf = getNextBuffer();
    final int bufRemaining = buf.remaining();
    if (bufRemaining > toRemoveAmount) {
      buf.position(buf.position() + toRemoveAmount);
      toRemoveAmount = 0;
    } else {
      currentBuffer++;
      toRemoveAmount -= bufRemaining;
    }
  }
  consumedSize += size;
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:22,代码来源:SimpleMergedByteBuffers.java


示例4: discardFromEnd

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public void discardFromEnd(int size) {
  ArgumentVerifier.assertNotNegative(size, "size");
  if (remaining() < size) {
    throw new BufferUnderflowException();
  }
  //We have logic here since we dont need to do any copying and we just drop the bytes
  int currentIndex = bba.length;
  int toRemoveAmount = size;
  while (toRemoveAmount > 0) {
    final ByteBuffer buf = bba[--currentIndex];
    final int bufRemaining = buf.remaining();
    if (bufRemaining > toRemoveAmount) {
      buf.limit(buf.limit() - toRemoveAmount);
      toRemoveAmount = 0;
    } else {
      bba[currentIndex] = IOUtils.EMPTY_BYTEBUFFER;
      toRemoveAmount -= bufRemaining;
    }
  }
  consumedSize += size;
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:23,代码来源:SimpleMergedByteBuffers.java


示例5: pullBuffer

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public ByteBuffer pullBuffer(final int size) {
  ArgumentVerifier.assertNotNegative(size, "size");
  if (size == 0) {
    return IOUtils.EMPTY_BYTEBUFFER;
  }
  if (currentSize < size) {
    throw new BufferUnderflowException();
  }
  consumedSize += size;
  currentSize -= size;
  final ByteBuffer first = availableBuffers.peek();
  if(first.remaining() == size) {
    return removeFirstBuffer().slice();
  } else if(first.remaining() > size) {
    final ByteBuffer bb = first.duplicate().slice();
    bb.limit(bb.position()+size);
    first.position(first.position()+size);
    return bb;
  } else {
    final byte[] result = new byte[size];
    doGet(result);
    return ByteBuffer.wrap(result);
  }
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:26,代码来源:ReuseableMergedByteBuffers.java


示例6: discard

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public void discard(final int size) {
  ArgumentVerifier.assertNotNegative(size, "size");
  if (currentSize < size) {
    throw new BufferUnderflowException();
  }
  //We have logic here since we dont need to do any copying and we just drop the bytes
  int toRemoveAmount = size;
  while (toRemoveAmount > 0) {
    final ByteBuffer buf = availableBuffers.peek();
    final int bufRemaining = buf.remaining();
    if (bufRemaining > toRemoveAmount) {
      buf.position(buf.position() + toRemoveAmount);
      toRemoveAmount = 0;
    } else {
      removeFirstBuffer();
      toRemoveAmount -= bufRemaining;
    }
  }
  consumedSize += size;
  currentSize -= size;
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:23,代码来源:ReuseableMergedByteBuffers.java


示例7: discardFromEnd

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public void discardFromEnd(int size) {
  ArgumentVerifier.assertNotNegative(size, "size");
  if (currentSize < size) {
    throw new BufferUnderflowException();
  }
  //We have logic here since we dont need to do any copying and we just drop the bytes
  int toRemoveAmount = size;
  while (toRemoveAmount > 0) {
    final ByteBuffer buf = availableBuffers.peekLast();
    final int bufRemaining = buf.remaining();
    if (bufRemaining > toRemoveAmount) {
      buf.limit(buf.limit() - toRemoveAmount);
      toRemoveAmount = 0;
    } else {
      removeLastBuffer();
      toRemoveAmount -= bufRemaining;
    }
  }
  consumedSize += size;
  currentSize -= size;
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:23,代码来源:ReuseableMergedByteBuffers.java


示例8: scheduleWithFixedDelay

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public void scheduleWithFixedDelay(Runnable task, long initialDelay, 
                                   long recurringDelay, TaskPriority priority) {
  ArgumentVerifier.assertNotNull(task, "task");
  ArgumentVerifier.assertNotNegative(initialDelay, "initialDelay");
  ArgumentVerifier.assertNotNegative(recurringDelay, "recurringDelay");
  if (priority == null) {
    priority = defaultPriority;
  }

  QueueSet queueSet = taskQueueManager.getQueueSet(priority);
  addToScheduleQueue(queueSet, 
                     new RecurringDelayTaskWrapper(task, queueSet, 
                                                   Clock.accurateForwardProgressingMillis() + 
                                                     initialDelay, 
                                                   recurringDelay));
}
 
开发者ID:threadly,项目名称:threadly,代码行数:18,代码来源:PriorityScheduler.java


示例9: scheduleAtFixedRate

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public void scheduleAtFixedRate(Runnable task, long initialDelay, long period, 
                                TaskPriority priority) {
  ArgumentVerifier.assertNotNull(task, "task");
  ArgumentVerifier.assertNotNegative(initialDelay, "initialDelay");
  ArgumentVerifier.assertGreaterThanZero(period, "period");
  if (priority == null) {
    priority = defaultPriority;
  }

  QueueSet queueSet = taskQueueManager.getQueueSet(priority);
  addToScheduleQueue(queueSet, 
                     new RecurringRateTaskWrapper(task, queueSet, 
                                                  Clock.accurateForwardProgressingMillis() + initialDelay, 
                                                  period));
}
 
开发者ID:threadly,项目名称:threadly,代码行数:17,代码来源:PriorityScheduler.java


示例10: WorkerPool

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
protected WorkerPool(ThreadFactory threadFactory, int poolSize) {
  ArgumentVerifier.assertGreaterThanZero(poolSize, "poolSize");
  if (threadFactory == null) {
    threadFactory = new ConfigurableThreadFactory(PriorityScheduler.class.getSimpleName() + "-", true);
  }
  
  poolSizeChangeLock = new Object();
  idleWorkerDequeLock = new Object();
  idleWorkerCount = new LongAdder();
  idleWorker = new AtomicReference<>(null);
  currentPoolSize = new AtomicInteger(0);
  workerStopNotifyLock = new Object();
  
  this.threadFactory = threadFactory;
  this.maxPoolSize = poolSize;
  this.workerTimedParkRunTime = Long.MAX_VALUE;
  shutdownStarted = new AtomicBoolean(false);
  shutdownFinishing = false;
}
 
开发者ID:threadly,项目名称:threadly,代码行数:20,代码来源:PriorityScheduler.java


示例11: setPoolSize

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
/**
 * Change the set core pool size.  If the value is less than the current max pool size, the max 
 * pool size will also be updated to this value.
 * <p>
 * If this was a reduction from the previous value, this call will examine idle workers to see 
 * if they should be expired.  If this call reduced the max pool size, and the current running 
 * thread count is higher than the new max size, this call will NOT block till the pool is 
 * reduced.  Instead as those workers complete, they will clean up on their own.
 * 
 * @param newPoolSize New core pool size, must be at least one
 */
public void setPoolSize(int newPoolSize) {
  ArgumentVerifier.assertGreaterThanZero(newPoolSize, "newPoolSize");
  
  if (newPoolSize == maxPoolSize) {
    // short cut the lock
    return;
  }
  
  boolean poolSizeIncrease;
  synchronized (poolSizeChangeLock) {
    poolSizeIncrease = newPoolSize > this.maxPoolSize;
    
    this.maxPoolSize = newPoolSize;
  }
  
  handleMaxPoolSizeChange(poolSizeIncrease);
}
 
开发者ID:threadly,项目名称:threadly,代码行数:29,代码来源:PriorityScheduler.java


示例12: shiftLocalHourToUTC

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
/**
 * This will shift an hour from the local time zone to UTC.  This shift will take into account 
 * the current local state of daylight savings time.  The primary usage of this is so that 
 * {@link #getDelayTillHour(int, int)} can be used with a local time zone hour.
 * 
 * @param hour Hour to be shifted in the local time zone in 24 hour format
 * @return Hour shifted to the UTC time zone in 24 hour format
 */
public static int shiftLocalHourToUTC(int hour) {
  ArgumentVerifier.assertLessThan(hour, TimeUnit.DAYS.toHours(1), "hour");
  ArgumentVerifier.assertNotNegative(hour, "hour");
  
  if (cachedHourShift == Integer.MIN_VALUE) {
    Calendar calendar = Calendar.getInstance();
    int shiftInMillis = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
    cachedHourShift = (int)(shiftInMillis / TimeUnit.HOURS.toMillis(1));
  }

  hour -= cachedHourShift;
  if (hour > TimeUnit.DAYS.toHours(1) - 1) {
    hour %= TimeUnit.DAYS.toHours(1);
  } else if (hour < 0) {
    hour += TimeUnit.DAYS.toHours(1);
  }
  
  return hour;
}
 
开发者ID:threadly,项目名称:threadly,代码行数:28,代码来源:SchedulingUtils.java


示例13: submitScheduled

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
/**
 * Schedule a {@link Callable} with a given delay.  This is needed when a result needs to be 
 * consumed from the callable.
 * 
 * @param <T> type of result returned from the future
 * @param threadKey object key where {@code equals()} will be used to determine execution thread
 * @param task callable to be executed
 * @param delayInMs time in milliseconds to wait to execute task
 * @return a future to know when the task has completed and get the result of the callable
 */
public <T> ListenableFuture<T> submitScheduled(Object threadKey, 
                                               Callable<T> task,  long delayInMs) {
  ArgumentVerifier.assertNotNull(threadKey, "threadKey");
  ArgumentVerifier.assertNotNull(task, "task");
  ArgumentVerifier.assertNotNegative(delayInMs, "delayInMs");

  ListenableRunnableFuture<T> rf = new ListenableFutureTask<>(false, task);
  
  if (delayInMs == 0) {
    addTask(threadKey, rf, executor);
  } else {
    scheduler.schedule(new AddTask(threadKey, rf), delayInMs);
  }
  
  return rf;
}
 
开发者ID:threadly,项目名称:threadly,代码行数:27,代码来源:KeyDistributedScheduler.java


示例14: scheduleWithFixedDelay

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public void scheduleWithFixedDelay(Runnable task, long initialDelay, long recurringDelay,
                                   TaskPriority priority) {
  ArgumentVerifier.assertNotNull(task, "task");
  ArgumentVerifier.assertNotNegative(initialDelay, "initialDelay");
  ArgumentVerifier.assertNotNegative(recurringDelay, "recurringDelay");
  if (priority == null) {
    priority = defaultPriority;
  }
  
  QueueSet queueSet = queueManager.getQueueSet(priority);
  NoThreadRecurringDelayTaskWrapper taskWrapper = 
      new NoThreadRecurringDelayTaskWrapper(task, queueSet, 
                                            nowInMillis(true) + initialDelay, recurringDelay);
  queueSet.addScheduled(taskWrapper);
}
 
开发者ID:threadly,项目名称:threadly,代码行数:17,代码来源:NoThreadScheduler.java


示例15: RateLimiterExecutor

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
/**
 * Constructs a new {@link RateLimiterExecutor}.  Tasks will be scheduled on the provided 
 * scheduler, so it is assumed that the scheduler will have enough threads to handle the 
 * average permit amount per task, per second.  
 * <p>
 * This constructor accepts a maximum schedule delay.  If a task requires being scheduled out 
 * beyond this delay, then the provided {@link RejectedExecutionHandler} will be invoked.
 * 
 * @since 4.8.0
 * @param scheduler scheduler to schedule/execute tasks on
 * @param permitsPerSecond how many permits should be allowed per second
 * @param maxScheduleDelayMillis Maximum amount of time delay tasks in order to maintain rate
 * @param rejectedExecutionHandler Handler to accept tasks which could not be executed
 */
public RateLimiterExecutor(SubmitterScheduler scheduler, double permitsPerSecond, 
                           long maxScheduleDelayMillis, 
                           RejectedExecutionHandler rejectedExecutionHandler) {
  ArgumentVerifier.assertNotNull(scheduler, "scheduler");
  
  this.scheduler = scheduler;
  if (rejectedExecutionHandler == null) {
    rejectedExecutionHandler = RejectedExecutionHandler.THROW_REJECTED_EXECUTION_EXCEPTION;
  }
  this.rejectedExecutionHandler = rejectedExecutionHandler;
  this.permitLock = new Object();
  this.lastScheduleTime = Clock.lastKnownForwardProgressingMillis();
  setPermitsPerSecond(permitsPerSecond);
  setMaxScheduleDelayMillis(maxScheduleDelayMillis);
}
 
开发者ID:threadly,项目名称:threadly,代码行数:30,代码来源:RateLimiterExecutor.java


示例16: scheduleAtFixedRate

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
@Override
public void scheduleAtFixedRate(Runnable task, long initialDelay, long period,
                                TaskPriority priority) {
  ArgumentVerifier.assertNotNull(task, "task");
  ArgumentVerifier.assertNotNegative(initialDelay, "initialDelay");
  ArgumentVerifier.assertGreaterThanZero(period, "period");
  if (priority == null) {
    priority = defaultPriority;
  }
  
  QueueSet queueSet = queueManager.getQueueSet(priority);
  
  NoThreadRecurringRateTaskWrapper taskWrapper = 
      new NoThreadRecurringRateTaskWrapper(task, queueSet, 
                                           nowInMillis(true) + initialDelay, period);
  queueSet.addScheduled(taskWrapper);
}
 
开发者ID:threadly,项目名称:threadly,代码行数:18,代码来源:NoThreadScheduler.java


示例17: setSteps

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
protected void setSteps(ExecutionItem[] steps) {
  ArgumentVerifier.assertNotNull(steps, "steps");
  if (this.steps == null) {
    throw new IllegalStateException("Run has completed");
  }
  
  this.steps = steps;
}
 
开发者ID:threadly,项目名称:ambush,代码行数:9,代码来源:AbstractScriptBuilder.java


示例18: AbstractScriptStep

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
protected AbstractScriptStep(CharSequence identifier, ScriptStepType stepType) {
  ArgumentVerifier.assertNotNull(stepType, "stepType");
  
  if (identifier instanceof String) {
    this.identifier = CharsDeduplicator.deDuplicate((String)identifier);
  } else if (identifier == null) {
    this.identifier = "";
  } else {
    this.identifier = identifier;
  }
  
  this.stepType = stepType;
}
 
开发者ID:threadly,项目名称:ambush,代码行数:14,代码来源:AbstractScriptStep.java


示例19: ExecutableScript

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
/**
 * Constructs a new {@link ExecutableScript}.  If the minimum threads needed don't match the 
 * execution graph provided, it may restrict load, or never complete.  
 * 
 * Execution will not proceed to the next step until the previous step has fully completed.
 * 
 * @param neededThreadQty Minimum number of threads to execute provided steps
 * @param startExecutionItem Execution item which represents the script
 */
public ExecutableScript(int neededThreadQty, ExecutionItem startExecutionItem) {
  if (! startExecutionItem.getChildItems().hasChildren()) {
    throw new IllegalArgumentException("Can not construct script with no steps");
  }
  ArgumentVerifier.assertGreaterThanZero(neededThreadQty, "neededThreadQty");
  
  this.neededThreadQty = neededThreadQty;
  this.startExecutionItem = startExecutionItem;
  scriptAssistant = new ScriptAssistant();
}
 
开发者ID:threadly,项目名称:ambush,代码行数:20,代码来源:ExecutableScript.java


示例20: initialize

import org.threadly.util.ArgumentVerifier; //导入依赖的package包/类
/**
 * Initializes the {@link ParameterStore} with the properties to load values used in the 
 * {@link #buildScript()}.  For that reason this should be called right after construction, and 
 * before {@link #buildScript()} is invoked.  This is not done in the constructor because 
 * extending classes should all have an empty (default) constructor.
 * 
 * @param properties Parameters to load values from
 */
protected void initialize(Properties properties) {
  ArgumentVerifier.assertNotNull(properties, "properties");
  if (this.properties != null) {
    throw new IllegalStateException("Alread initialized");
  }
  
  this.properties = properties;
}
 
开发者ID:threadly,项目名称:ambush,代码行数:17,代码来源:ParameterStore.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ToolBarBuilder类代码示例发布时间:2022-05-22
下一篇:
Java BitmapLoadUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap