org.apache.blur.utils
Class BlurUtil

java.lang.Object
  extended by org.apache.blur.utils.BlurUtil

public class BlurUtil
extends Object


Field Summary
static Comparator<? super BlurResult> HITS_COMPARATOR
           
static Comparator<? super PeekableIterator<BlurResult,BlurException>> HITS_PEEKABLE_ITERATOR_COMPARATOR
           
static org.apache.lucene.index.Term PRIME_DOC_TERM
           
static SortFieldComparator SORT_FIELD_COMPARATOR
           
 
Constructor Summary
BlurUtil()
           
 
Method Summary
static
<T> T
configure(T t)
           
static
<T,E extends Exception>
BlurIterator<T,E>
convert(Iterator<T> iterator)
           
static BlurResults convertToHits(BlurResultIterable hitsIterable, BlurQuery query, java.util.concurrent.atomic.AtomicLongArray facetCounts, java.util.concurrent.ExecutorService executor, Selector selector, Blur.Iface iface, String table)
           
static SortFieldResult convertToSortField(Object o)
           
static List<SortFieldResult> convertToSortFields(Object[] fields)
           
static int countDocuments(org.apache.lucene.index.IndexReader reader, org.apache.lucene.index.Term term)
           
static void createIfMissing(org.apache.zookeeper.ZooKeeper zookeeper, String path)
           
static boolean createPath(org.apache.hadoop.fs.FileSystem fileSystem, org.apache.hadoop.fs.Path path)
           
static void createPath(org.apache.zookeeper.ZooKeeper zookeeper, String path, byte[] data)
           
static List<org.apache.lucene.document.Document> fetchDocuments(org.apache.lucene.index.IndexReader reader, ResetableDocumentStoredFieldVisitor fieldSelector, Selector selector, int maxHeap, String context, org.apache.lucene.index.Term primeDocTerm, org.apache.lucene.search.Filter filter, java.util.concurrent.atomic.AtomicBoolean moreToFetch, java.util.concurrent.atomic.AtomicInteger totalRecords, BlurHighlighter highlighter)
          NOTE: This is a potentially dangerous call, it will return all the documents that match the term.
static Serializable fromBytes(byte[] bs)
           
static Serializable fromBytes(byte[] bs, int offset, int length)
           
static String getArgsStr(Object[] args, org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
           
static String getArgsStr(Object[] args, String methodName, org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
           
static String getArgsStr(Object o, org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
           
static String getArgsStr(TBase o, org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)
           
static java.util.concurrent.atomic.AtomicLongArray getAtomicLongArraySameLengthAsList(List<?> list)
           
static org.apache.lucene.index.AtomicReader getAtomicReader(org.apache.lucene.index.IndexReader reader)
           
static String getErrorResponseLogMessage(String requestId, String connectionString, String argsStr, String name, double ms, User user)
           
static
<T> T
getInstance(String className, Class<T> c)
           
static List<Long> getList(java.util.concurrent.atomic.AtomicLongArray atomicLongArray)
           
static String getPid()
           
static String getRequestLogMessage(String requestId, String connectionString, String argsStr, String name, User user)
           
static String getResponseLogMessage(String requestId, String connectionString, String argsStr, String name, double ms, User user, boolean success)
           
static org.apache.lucene.index.SegmentReader getSegmentReader(org.apache.lucene.index.IndexReader indexReader)
           
static int getShardIndex(String shard)
           
static String getShardName(int id)
           
static String getShardName(String prefix, int id)
           
static String getSuccessfulResponseLogMessage(String requestId, String connectionString, String argsStr, String name, double ms, User user)
           
static String getVersion()
           
static String humanizeTime(long hours, long minutes, long seconds)
           
static String humanizeTime(long time, java.util.concurrent.TimeUnit unit)
           
static
<T extends Blur.Iface>
T
lastChanceErrorHandling(T t, Class<T> clazz)
           
static String lockForSafeMode(org.apache.zookeeper.ZooKeeper zookeeper, String nodeName, String cluster)
           
static
<T> T
nullCheck(T t, String message)
           
static void quietClose(Object... close)
           
static byte[] read(TBase<?,?> base)
           
static
<T extends Blur.Iface>
T
recordMethodCallsAndAverageTimes(T t, Class<T> clazz, boolean controller)
           
static void removeAll(org.apache.zookeeper.ZooKeeper zooKeeper, String path)
           
static void removeIndexFiles(String uri)
           
static Blur.Iface runTrace(Blur.Iface iface, boolean controller)
           
static Blur.Iface runWithUser(Blur.Iface iface, boolean controller)
           
static void setStartTime(BlurQuery query)
           
static void setupFileSystem(String uri, int shardCount)
           
static void setupZookeeper(org.apache.zookeeper.ZooKeeper zookeeper)
           
static void setupZookeeper(org.apache.zookeeper.ZooKeeper zookeeper, String cluster)
           
static byte[] toBytes(Serializable serializable)
           
static List<Long> toList(java.util.concurrent.atomic.AtomicLongArray atomicLongArray)
           
static RecordMutation toRecordMutation(Record record)
           
static RowMutation toRowMutation(String table, Row row)
           
static String toString(byte[] b, int off, int len)
           
static String toStringBinary(byte[] b, int off, int len)
           
static void unlockForSafeMode(org.apache.zookeeper.ZooKeeper zookeeper, String lockPath)
           
static boolean validate(String s)
           
static void validateRowIdAndRecord(String rowId, Record record)
           
static void validateShardCount(int shardCount, org.apache.hadoop.fs.FileSystem fileSystem, org.apache.hadoop.fs.Path tablePath)
           
static void validateShardName(String shardName)
           
static void validateTableName(String tableName)
           
static void validateWritableDirectory(org.apache.hadoop.fs.FileSystem fileSystem, org.apache.hadoop.fs.Path tablePath)
           
static Blur.Iface wrapFilteredBlurServer(BlurConfiguration configuration, Blur.Iface iface, boolean shard)
           
static void write(byte[] data, TBase<?,?> base)
           
static int zeroCheck(int i, String message)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SORT_FIELD_COMPARATOR

public static final SortFieldComparator SORT_FIELD_COMPARATOR

HITS_PEEKABLE_ITERATOR_COMPARATOR

public static final Comparator<? super PeekableIterator<BlurResult,BlurException>> HITS_PEEKABLE_ITERATOR_COMPARATOR

HITS_COMPARATOR

public static final Comparator<? super BlurResult> HITS_COMPARATOR

PRIME_DOC_TERM

public static final org.apache.lucene.index.Term PRIME_DOC_TERM
Constructor Detail

BlurUtil

public BlurUtil()
Method Detail

lastChanceErrorHandling

public static <T extends Blur.Iface> T lastChanceErrorHandling(T t,
                                                               Class<T> clazz)

recordMethodCallsAndAverageTimes

public static <T extends Blur.Iface> T recordMethodCallsAndAverageTimes(T t,
                                                                        Class<T> clazz,
                                                                        boolean controller)

getArgsStr

public static String getArgsStr(Object[] args,
                                String methodName,
                                org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)

getArgsStr

public static String getArgsStr(Object[] args,
                                org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)

getArgsStr

public static String getArgsStr(Object o,
                                org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)

getArgsStr

public static String getArgsStr(TBase o,
                                org.apache.blur.utils.BlurUtil.LoggerArgsState loggerArgsState)

getRequestLogMessage

public static String getRequestLogMessage(String requestId,
                                          String connectionString,
                                          String argsStr,
                                          String name,
                                          User user)

getResponseLogMessage

public static String getResponseLogMessage(String requestId,
                                           String connectionString,
                                           String argsStr,
                                           String name,
                                           double ms,
                                           User user,
                                           boolean success)

getSuccessfulResponseLogMessage

public static String getSuccessfulResponseLogMessage(String requestId,
                                                     String connectionString,
                                                     String argsStr,
                                                     String name,
                                                     double ms,
                                                     User user)

getErrorResponseLogMessage

public static String getErrorResponseLogMessage(String requestId,
                                                String connectionString,
                                                String argsStr,
                                                String name,
                                                double ms,
                                                User user)

setupZookeeper

public static void setupZookeeper(org.apache.zookeeper.ZooKeeper zookeeper)
                           throws org.apache.zookeeper.KeeperException,
                                  InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

setupZookeeper

public static void setupZookeeper(org.apache.zookeeper.ZooKeeper zookeeper,
                                  String cluster)
                           throws org.apache.zookeeper.KeeperException,
                                  InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

createIfMissing

public static void createIfMissing(org.apache.zookeeper.ZooKeeper zookeeper,
                                   String path)
                            throws org.apache.zookeeper.KeeperException,
                                   InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

getList

public static List<Long> getList(java.util.concurrent.atomic.AtomicLongArray atomicLongArray)

quietClose

public static void quietClose(Object... close)

toBytes

public static byte[] toBytes(Serializable serializable)

fromBytes

public static Serializable fromBytes(byte[] bs)

fromBytes

public static Serializable fromBytes(byte[] bs,
                                     int offset,
                                     int length)

toList

public static List<Long> toList(java.util.concurrent.atomic.AtomicLongArray atomicLongArray)

getAtomicLongArraySameLengthAsList

public static java.util.concurrent.atomic.AtomicLongArray getAtomicLongArraySameLengthAsList(List<?> list)

convertToHits

public static BlurResults convertToHits(BlurResultIterable hitsIterable,
                                        BlurQuery query,
                                        java.util.concurrent.atomic.AtomicLongArray facetCounts,
                                        java.util.concurrent.ExecutorService executor,
                                        Selector selector,
                                        Blur.Iface iface,
                                        String table)
                                 throws InterruptedException,
                                        java.util.concurrent.ExecutionException,
                                        BlurException
Throws:
InterruptedException
java.util.concurrent.ExecutionException
BlurException

setStartTime

public static void setStartTime(BlurQuery query)

getVersion

public static String getVersion()

unlockForSafeMode

public static void unlockForSafeMode(org.apache.zookeeper.ZooKeeper zookeeper,
                                     String lockPath)
                              throws InterruptedException,
                                     org.apache.zookeeper.KeeperException
Throws:
InterruptedException
org.apache.zookeeper.KeeperException

lockForSafeMode

public static String lockForSafeMode(org.apache.zookeeper.ZooKeeper zookeeper,
                                     String nodeName,
                                     String cluster)
                              throws org.apache.zookeeper.KeeperException,
                                     InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

getShardName

public static String getShardName(int id)

getShardName

public static String getShardName(String prefix,
                                  int id)

humanizeTime

public static String humanizeTime(long time,
                                  java.util.concurrent.TimeUnit unit)

humanizeTime

public static String humanizeTime(long hours,
                                  long minutes,
                                  long seconds)

createPath

public static void createPath(org.apache.zookeeper.ZooKeeper zookeeper,
                              String path,
                              byte[] data)
                       throws org.apache.zookeeper.KeeperException,
                              InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

setupFileSystem

public static void setupFileSystem(String uri,
                                   int shardCount)
                            throws IOException
Throws:
IOException

validateShardCount

public static void validateShardCount(int shardCount,
                                      org.apache.hadoop.fs.FileSystem fileSystem,
                                      org.apache.hadoop.fs.Path tablePath)
                               throws IOException
Throws:
IOException

createPath

public static boolean createPath(org.apache.hadoop.fs.FileSystem fileSystem,
                                 org.apache.hadoop.fs.Path path)
                          throws IOException
Throws:
IOException

zeroCheck

public static int zeroCheck(int i,
                            String message)

nullCheck

public static <T> T nullCheck(T t,
                              String message)

getInstance

public static <T> T getInstance(String className,
                                Class<T> c)

configure

public static <T> T configure(T t)

read

public static byte[] read(TBase<?,?> base)

write

public static void write(byte[] data,
                         TBase<?,?> base)

removeAll

public static void removeAll(org.apache.zookeeper.ZooKeeper zooKeeper,
                             String path)
                      throws org.apache.zookeeper.KeeperException,
                             InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

removeIndexFiles

public static void removeIndexFiles(String uri)
                             throws IOException
Throws:
IOException

toRowMutation

public static RowMutation toRowMutation(String table,
                                        Row row)

toRecordMutation

public static RecordMutation toRecordMutation(Record record)

countDocuments

public static int countDocuments(org.apache.lucene.index.IndexReader reader,
                                 org.apache.lucene.index.Term term)
                          throws IOException
Throws:
IOException

fetchDocuments

public static List<org.apache.lucene.document.Document> fetchDocuments(org.apache.lucene.index.IndexReader reader,
                                                                       ResetableDocumentStoredFieldVisitor fieldSelector,
                                                                       Selector selector,
                                                                       int maxHeap,
                                                                       String context,
                                                                       org.apache.lucene.index.Term primeDocTerm,
                                                                       org.apache.lucene.search.Filter filter,
                                                                       java.util.concurrent.atomic.AtomicBoolean moreToFetch,
                                                                       java.util.concurrent.atomic.AtomicInteger totalRecords,
                                                                       BlurHighlighter highlighter)
                                                                throws IOException
NOTE: This is a potentially dangerous call, it will return all the documents that match the term.

Parameters:
selector -
primeDocTerm -
filter -
totalRecords -
highlighter -
Throws:
IOException

getSegmentReader

public static org.apache.lucene.index.SegmentReader getSegmentReader(org.apache.lucene.index.IndexReader indexReader)

getAtomicReader

public static org.apache.lucene.index.AtomicReader getAtomicReader(org.apache.lucene.index.IndexReader reader)
                                                            throws IOException
Throws:
IOException

getShardIndex

public static int getShardIndex(String shard)

validateRowIdAndRecord

public static void validateRowIdAndRecord(String rowId,
                                          Record record)

validate

public static boolean validate(String s)

validateTableName

public static void validateTableName(String tableName)

validateShardName

public static void validateShardName(String shardName)

getPid

public static String getPid()

convert

public static <T,E extends Exception> BlurIterator<T,E> convert(Iterator<T> iterator)

validateWritableDirectory

public static void validateWritableDirectory(org.apache.hadoop.fs.FileSystem fileSystem,
                                             org.apache.hadoop.fs.Path tablePath)
                                      throws IOException
Throws:
IOException

wrapFilteredBlurServer

public static Blur.Iface wrapFilteredBlurServer(BlurConfiguration configuration,
                                                Blur.Iface iface,
                                                boolean shard)

runWithUser

public static Blur.Iface runWithUser(Blur.Iface iface,
                                     boolean controller)

runTrace

public static Blur.Iface runTrace(Blur.Iface iface,
                                  boolean controller)

convertToSortFields

public static List<SortFieldResult> convertToSortFields(Object[] fields)

convertToSortField

public static SortFieldResult convertToSortField(Object o)

toStringBinary

public static String toStringBinary(byte[] b,
                                    int off,
                                    int len)

toString

public static String toString(byte[] b,
                              int off,
                              int len)


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.