private ExtendableThreadPoolExecutor createQueryExecutor() { TaskQueue queue = new TaskQueue(SysProperties.THREAD_QUEUE_SIZE); int poolCoreSize = SysProperties.THREAD_POOL_SIZE_CORE; int poolMaxSize = SysProperties.THREAD_POOL_SIZE_MAX; poolMaxSize = poolMaxSize > poolCoreSize ? poolMaxSize : poolCoreSize; ExtendableThreadPoolExecutor queryExecutor = new ExtendableThreadPoolExecutor(poolCoreSize, poolMaxSize, 2L, TimeUnit.MINUTES, queue, Threads.newThreadFactory("ddal-query-executor")); return queryExecutor; }
/** * Copy a file from one directory to another, or to another file. * * @param original the original file name * @param copy the file name of the copy */ public static void copyFiles(String original, String copy) throws IOException { InputStream in = FileUtils.newInputStream(original); OutputStream out = FileUtils.newOutputStream(copy, false); copyAndClose(in, out); }
private void appendKeyCondition(StatementBuilder buff) { buff.append(" WHERE "); buff.resetCount(); for (String k : key) { buff.appendExceptFirst(" AND "); buff.append(StringUtils.quoteIdentifier(k)).append("=?"); } }
protected Function(Database database, FunctionInfo info) { this.database = database; this.info = info; if (info.parameterCount == VAR_ARGS) { varArgs = New.arrayList(); } else { args = new Expression[info.parameterCount]; } }
public ExtendableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, TaskQueue workQueue, ThreadFactory threadFactory) { super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, new RejectHandler()); workQueue.setParent(this); }
/** * Check if the file name includes a path. This method is similar to Java 7 * <code>java.nio.file.Path.isAbsolute</code>. * * @param fileName the file name * @return if the file name is absolute */ public static boolean isAbsolute(String fileName) { return FilePath.get(fileName).isAbsolute(); }
/** * Get the size of a file in bytes * This method is similar to Java 7 * <code>java.nio.file.attribute.Attributes. * readBasicFileAttributes(file).size()</code> * * @param fileName the file name * @return the size in bytes */ public static long size(String fileName) { return FilePath.get(fileName).size(); }
/** * Check if it is a file or a directory. * <code>java.nio.file.attribute.Attributes. * readBasicFileAttributes(file).isDirectory()</code> * * @param fileName the file or directory name * @return true if it is a directory */ public static boolean isDirectory(String fileName) { return FilePath.get(fileName).isDirectory(); }
/** * Create an input stream to read from the file. * This method is similar to Java 7 * <code>java.nio.file.Path.newInputStream</code>. * * @param fileName the file name * @return the input stream */ public static InputStream newInputStream(String fileName) throws IOException { return FilePath.get(fileName).newInputStream(); }
public void close() { if (scheduledExecutor != null) { Threads.shutdownGracefully(scheduledExecutor, 1000, 1000, TimeUnit.MILLISECONDS); } }
/** * Load the driver class for the given URL, if the database URL is known. * * @param url the database URL */ public static void load(String url) { String driver = getDriver(url); if (driver != null) { loadUserClass(driver); } }
/** * {@inheritDoc} */ @Override public void execute(Runnable command) { execute(command,0,TimeUnit.MILLISECONDS); }
/** * Create a new permutations object. * * @param <T> the type * @param in the source array * @param out the target array * @return the generated permutations object */ public static <T> Permutations<T> create(T[] in, T[] out) { return new Permutations<T>(in, out, in.length); }
/** * Create an XML node with optional attributes and content. * The data is indented with 4 spaces if it contains a newline character. * * @param name the element name * @param attributes the attributes (may be null) * @param content the content (may be null) * @return the node */ public static String xmlNode(String name, String attributes, String content) { return xmlNode(name, attributes, content, true); }
/** * Set bit at the given index to 'false'. * * @param i the index */ public void clear(int i) { int addr = i >> ADDRESS_BITS; if (addr >= data.length) { return; } data[addr] &= ~getBitMask(i); }
/** * Format an int array to the Java source code that represents this object. * * @param s the int array to convert * @return the Java source code */ protected static String quoteIntArray(int[] s) { return StringUtils.quoteJavaIntArray(s); }
private ThreadPoolExecutor createUserThreadExecutor() { TaskQueue queue = new TaskQueue(SysProperties.THREAD_QUEUE_SIZE); int poolCoreSize = SysProperties.THREAD_POOL_SIZE_CORE; int poolMaxSize = SysProperties.THREAD_POOL_SIZE_MAX; poolMaxSize = poolMaxSize > poolCoreSize ? poolMaxSize : poolCoreSize; ExtendableThreadPoolExecutor userExecutor = new ExtendableThreadPoolExecutor(poolCoreSize, poolMaxSize, 5L, TimeUnit.MINUTES, queue, Threads.newThreadFactory("request-processor")); return userExecutor; }