/** * Sets batch size. * * @param batchSize Batch size. * @return {@code this} for chaining. */ public AbstractEvictionPolicyFactory setBatchSize(int batchSize) { A.ensure(batchSize > 0, "batchSize > 0"); this.batchSize = batchSize; return this; }
/** * Sets maximum allowed cache size in bytes. * * @return {@code this} for chaining. */ public AbstractEvictionPolicyFactory setMaxMemorySize(long maxMemSize) { A.ensure(maxMemSize >= 0, "maxMemSize >= 0"); this.maxMemSize = maxMemSize; return this; }
/** {@inheritDoc} */ @Override public CacheQuery<T> pageSize(int pageSize) { A.ensure(pageSize > 0, "pageSize > 0"); this.pageSize = pageSize; return this; }
/** {@inheritDoc} */ @Override public CacheQuery<T> timeout(long timeout) { A.ensure(timeout >= 0, "timeout >= 0"); this.timeout = timeout; return this; }
/** * Sets the number of pre-fetched blocks if specific file's chunk is requested. * * @param prefetchBlocks New number of pre-fetched blocks. * @return {@code this} for chaining. */ public FileSystemConfiguration setPrefetchBlocks(int prefetchBlocks) { A.ensure(prefetchBlocks >= 0, "prefetchBlocks >= 0"); this.prefetchBlocks = prefetchBlocks; return this; }
/** * Sets max size. Default value {@link #DEFAULT_QUEUE_SIZE} * * @param maxSize Max size. */ public void setMaxSize(int maxSize) { A.ensure(maxSize > 0, "Max queue size must be greater than 0."); this.maxSize = maxSize; }
/** * Sets the polling timeout for Kafka tasks. * * @param timeout Timeout. */ public void setTimeout(long timeout) { A.ensure(timeout > 0, "timeout > 0"); this.timeout = timeout; }
/** * @param p1 Part 1. * @param p2 Part 2. */ private void validateDups(int p1, int p2) { A.ensure(p1 != p2, "Partition duplicates are not allowed: " + p1); }
/** * Sets maximum allowed cache size in bytes. * @return {@code this} for chaining. */ public AbstractEvictionPolicy<K, V> setMaxMemorySize(long maxMemSize) { A.ensure(maxMemSize >= 0, "maxMemSize >= 0"); this.maxMemSize = maxMemSize; return this; }
/** * Sets maximum allowed size of cache before entry will start getting evicted. * * @param max Maximum allowed size of cache before entry will start getting evicted. * @return {@code this} for chaining. */ public AbstractEvictionPolicy<K, V> setMaxSize(int max) { A.ensure(max >= 0, "max >= 0"); this.max = max; return this; }
/** * @param attributeNames The list of attribute names for the set of attributes to compare. Must be at least one. */ public ClusterNodeAttributeAffinityBackupFilter(String... attributeNames) { A.ensure(attributeNames.length > 0, "attributeNames.length > 0"); this.attributeNames = attributeNames; }
/** * @throws IllegalArgumentException If validation failed. */ public void validate() throws IllegalArgumentException { A.ensure(pageSize >= 1024 && pageSize <= 16 * 1024, "Page size must be between 1kB and 16kB."); A.ensure(U.isPow2(pageSize), "Page size must be a power of 2."); A.ensure(bufferSize >= pageSize * 2, "Buffer to small."); A.ensure(sharedCtx == null || (binaryMetadataFileStoreDir == null && marshallerMappingFileStoreDir == null), "GridCacheSharedContext and binaryMetadataFileStoreDir/" + "marshallerMappingFileStoreDir can't be specified in the same time"); }
/** * @param size Size. */ public GridCircularBuffer(int size) { A.ensure(size > 0, "Size should be greater than 0: " + size); A.ensure((size & (size - 1)) == 0, "Size should be power of two: " + size); sizeMask = size - 1; arr = (Item<T>[])new Item[size]; // Fill the array. for (int i = 0; i < arr.length; i++) arr[i] = new Item<>(); }
/** * @param rateTimeInterval Rate time interval. * @param size Number of counters. */ public HitRateMetrics(int rateTimeInterval, int size) { A.ensure(rateTimeInterval > 0, "should be positive"); A.ensure(size > 1, "minimum is 2"); this.rateTimeInterval = rateTimeInterval; this.size = size; taggedCounters = new AtomicLongArray(size); lastHitTimes = new AtomicLongArray(size); }
/** * Sets number of jobs that can be executed in parallel. * * @param activeJobsThreshold Number of jobs that can be executed in parallel. */ @IgniteSpiConfiguration(optional = true) public JobStealingCollisionSpi setActiveJobsThreshold(int activeJobsThreshold) { A.ensure(activeJobsThreshold >= 0, "activeJobsThreshold >= 0"); this.activeJobsThreshold = activeJobsThreshold; return this; }
/** {@inheritDoc} */ @Override public R get(long timeout, TimeUnit unit) throws IgniteCheckedException { A.ensure(timeout >= 0, "timeout cannot be negative: " + timeout); A.notNull(unit, "unit"); return get0(ignoreInterrupts, unit.toNanos(timeout)); }
/** * @param name Cache name. * @throws IllegalArgumentException In case the name is not valid. */ public static void validateNewCacheName(String name) throws IllegalArgumentException { validateCacheName(name); A.ensure(!isReservedCacheName(name), "Cache name cannot be \"" + name + "\" because it is reserved for internal purposes."); }
/** {@inheritDoc} */ @Override public R get(long timeout, TimeUnit unit) throws GridClientException { A.ensure(timeout >= 0, "timeout >= 0"); try { if (!done && !tryAcquireSharedNanos(0, unit.toNanos(timeout))) throw new GridClientFutureTimeoutException("Failed to get future result due to waiting timed out."); } catch (InterruptedException e) { throw new GridClientException("Operation was interrupted.", e); } return getResult(); }
/** {@inheritDoc} */ @Override public Closeable runLocal(@Nullable Runnable r, long delay, TimeUnit timeUnit) { A.notNull(r, "r"); A.ensure(delay > 0, "Illegal delay"); guard(); try { return ctx.timeout().schedule(r, timeUnit.toMillis(delay), -1); } finally { unguard(); } }
/** {@inheritDoc} */ @Override protected Object executeJob(int gridSize, String arg) { A.notNull(arg, "task argument"); String[] split = arg.split(":", 2); A.ensure(split.length == 2, "Task argument should have format 'cacheName:affinityKey'."); String cacheName = split[0]; String affKey = split[1]; if ("null".equals(cacheName)) cacheName = null; ClusterNode node = ignite.affinity(cacheName).mapKeyToNode(affKey); return node.id().toString(); }