code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
private List<Stat> getStats() throws Exception {
List<String> topics = mZookeeperConnector.getCommittedOffsetTopics();
List<Stat> stats = Lists.newArrayList();
for (String topic : topics) {
if (topic.matches(mConfig.getMonitoringBlacklistTopics()) ||
!topic.match... | Helper to publish stats to statsD client | getStats | java | pinterest/secor | src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | Apache-2.0 |
private String metricName(String key) {
return Joiner.on(".").join(mPrefix, key);
} | Helper to publish stats to statsD client | metricName | java | pinterest/secor | src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | Apache-2.0 |
private long getTimestamp(Message message) throws Exception {
if (mMessageParser instanceof TimestampedMessageParser) {
return ((TimestampedMessageParser)mMessageParser).getTimestampMillis(message);
} else {
return -1;
}
} | Helper to publish stats to statsD client | getTimestamp | java | pinterest/secor | src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | Apache-2.0 |
public String getName() {
return this.mName;
} | JSON hash map extension to store statistics | getName | java | pinterest/secor | src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | Apache-2.0 |
public static Stat createInstance(String metric, Map<String, String> tags, String value, long timestamp) {
return new Stat(ImmutableMap.of(
STAT_KEYS.METRIC.getName(), metric,
STAT_KEYS.TAGS.getName(), tags,
STAT_KEYS.VALUE.getName(), value,
... | JSON hash map extension to store statistics | createInstance | java | pinterest/secor | src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/tools/ProgressMonitor.java | Apache-2.0 |
@java.lang.Override
public Handle<?> upload(LogFilePath localPath) throws Exception {
final String azureContainer = mConfig.getAzureContainer();
final String azureKey = localPath.withPrefix(mConfig.getAzurePath()).getLogFilePath();
final File localFile = new File(localPath.getLogFilePath());... | Manages uploads to Microsoft Azure blob storage using Azure Storage SDK for java
https://github.com/azure/azure-storage-java
@author Taichi Nakashima (nsd22843@gmail.com) | upload | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/AzureUploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/AzureUploadManager.java | Apache-2.0 |
@Override
public void run() {
try {
CloudBlobContainer container = blobClient.getContainerReference(azureContainer);
container.createIfNotExists();
CloudBlockBlob blob = container.getBlockBlobReference(azureKey);
... | Manages uploads to Microsoft Azure blob storage using Azure Storage SDK for java
https://github.com/azure/azure-storage-java
@author Taichi Nakashima (nsd22843@gmail.com) | run | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/AzureUploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/AzureUploadManager.java | Apache-2.0 |
public T get() throws Exception {
return mFuture.get();
} | Wraps a Future. `get` blocks until the underlying Future completes.
@author Liam Stewart (liam.stewart@gmail.com) | get | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/FutureHandle.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/FutureHandle.java | Apache-2.0 |
@Override
public Handle<?> upload(LogFilePath localPath) throws Exception {
final String gsBucket = mConfig.getGsBucket();
final String gsKey = localPath.withPrefix(mConfig.getGsPath()).getLogFilePath();
final File localFile = new File(localPath.getLogFilePath());
final boolean direc... | Global instance of the Storage. The best practice is to make it a single
globally shared instance across your application. | upload | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/GsUploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/GsUploadManager.java | Apache-2.0 |
@Override
public void run() {
try {
if (directUpload) {
byte[] content = Files.readAllBytes(localFile.toPath());
Blob result = mClient.create(sourceBlob, content);
LOG.debug("Upload file {} to gs://{}... | Global instance of the Storage. The best practice is to make it a single
globally shared instance across your application. | run | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/GsUploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/GsUploadManager.java | Apache-2.0 |
private static Storage getService(String credentialsPath, int connectTimeoutMs, int readTimeoutMs) throws Exception {
if (mStorageService == null) {
StorageOptions.Builder builder;
if (credentialsPath != null && !credentialsPath.isEmpty()) {
try (FileInputStream fis = n... | Global instance of the Storage. The best practice is to make it a single
globally shared instance across your application. | getService | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/GsUploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/GsUploadManager.java | Apache-2.0 |
public Handle<?> upload(LogFilePath localPath) throws Exception {
String prefix = FileUtil.getPrefix(localPath.getTopic(), mConfig);
LogFilePath path = localPath.withPrefix(prefix);
final String localLogFilename = localPath.getLogFilePath();
final String logFileName;
if (FileUti... | Manages uploads to S3 using the Hadoop API.
@author Pawel Garbacki (pawel@pinterest.com) | upload | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/HadoopS3UploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/HadoopS3UploadManager.java | Apache-2.0 |
@Override
public void run() {
try {
FileUtil.moveToCloud(localLogFilename, logFileName);
} catch (IOException e) {
throw new RuntimeException(e);
}
} | Manages uploads to S3 using the Hadoop API.
@author Pawel Garbacki (pawel@pinterest.com) | run | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/HadoopS3UploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/HadoopS3UploadManager.java | Apache-2.0 |
public UploadResult get() throws Exception {
return mUpload.waitForUploadResult();
} | Wraps an Upload being managed by the AWS SDK TransferManager. `get`
blocks until the upload completes.
@author Liam Stewart (liam.stewart@gmail.com) | get | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/S3UploadHandle.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/S3UploadHandle.java | Apache-2.0 |
public AWSCredentials getCredentials() {
if (sessionToken.isEmpty()) {
return new BasicAWSCredentials(accessKey, secretKey);
} else {
return new BasicSessionCredentials(accessKey, secretKey, sessionToken);
}
... | Manages uploads to S3 using the TransferManager class from the AWS
SDK.
<p>
Set the <code>aws.sse.type</code> property to specify the type of
encryption to use. Supported options are:
<code>S3</code>, <code>KMS</code> and <code>customer</code>. See AWS
documentation for Server-Side Encryption (SSE) for details on these... | getCredentials | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | Apache-2.0 |
public Handle<?> upload(LogFilePath localPath) throws Exception {
String s3Bucket = mConfig.getS3Bucket();
String curS3Path = s3Path;
String s3Key;
File localFile = new File(localPath.getLogFilePath());
if (FileUtil.s3PathPrefixIsAltered(localPath.withPrefix(curS3Path).getLogFi... | Manages uploads to S3 using the TransferManager class from the AWS
SDK.
<p>
Set the <code>aws.sse.type</code> property to specify the type of
encryption to use. Supported options are:
<code>S3</code>, <code>KMS</code> and <code>customer</code>. See AWS
documentation for Server-Side Encryption (SSE) for details on these... | upload | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | Apache-2.0 |
private void enableCustomerEncryption(PutObjectRequest uploadRequest) {
SSECustomerKey sseKey = new SSECustomerKey(mConfig.getAwsSseCustomerKey());
uploadRequest.withSSECustomerKey(sseKey);
} | Manages uploads to S3 using the TransferManager class from the AWS
SDK.
<p>
Set the <code>aws.sse.type</code> property to specify the type of
encryption to use. Supported options are:
<code>S3</code>, <code>KMS</code> and <code>customer</code>. See AWS
documentation for Server-Side Encryption (SSE) for details on these... | enableCustomerEncryption | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | Apache-2.0 |
private void enableKmsEncryption(PutObjectRequest uploadRequest) {
String keyId = mConfig.getAwsSseKmsKey();
if (!keyId.isEmpty()) {
uploadRequest.withSSEAwsKeyManagementParams(new SSEAwsKeyManagementParams(keyId));
} else {
uploadRequest.withSSEAwsKeyManagementParams(new... | Manages uploads to S3 using the TransferManager class from the AWS
SDK.
<p>
Set the <code>aws.sse.type</code> property to specify the type of
encryption to use. Supported options are:
<code>S3</code>, <code>KMS</code> and <code>customer</code>. See AWS
documentation for Server-Side Encryption (SSE) for details on these... | enableKmsEncryption | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | Apache-2.0 |
private void enableS3Encryption(PutObjectRequest uploadRequest) {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
uploadRequest.setMetadata(objectMetadata);
} | Manages uploads to S3 using the TransferManager class from the AWS
SDK.
<p>
Set the <code>aws.sse.type</code> property to specify the type of
encryption to use. Supported options are:
<code>S3</code>, <code>KMS</code> and <code>customer</code>. See AWS
documentation for Server-Side Encryption (SSE) for details on these... | enableS3Encryption | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/S3UploadManager.java | Apache-2.0 |
public void init(SecorConfig config, OffsetTracker offsetTracker, FileRegistry fileRegistry,
UploadManager uploadManager, MessageReader messageReader, MetricCollector metricCollector,
DeterministicUploadPolicyTracker deterministicUploadPolicyTracker) {
init(config, offs... | Init the Uploader with its dependent objects.
@param config Secor configuration
@param offsetTracker Tracker of the current offset of topics partitions
@param fileRegistry Registry of log files on a per-topic and per-partition basis
@param uploadManager Manager of the physical upload of log files to the remote reposit... | init | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
public void init(SecorConfig config, OffsetTracker offsetTracker, FileRegistry fileRegistry,
UploadManager uploadManager, MessageReader messageReader,
ZookeeperConnector zookeeperConnector, MetricCollector metricCollector,
DeterministicUploadPolicyTracker d... | Init the Uploader with its dependent objects.
@param config Secor configuration
@param offsetTracker Tracker of the current offset of topics partitions
@param fileRegistry Registry of log files on a per-topic and per-partition basis
@param uploadManager Manager of the physical upload of log files to the remote reposit... | init | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
protected void uploadFiles(TopicPartition topicPartition) throws Exception {
LOG.debug("Uploading for: " + topicPartition);
long committedOffsetCount = mOffsetTracker.getTrueCommittedOffsetCount(topicPartition);
long lastSeenOffset = mOffsetTracker.getLastSeenOffset(topicPartition);
Str... | Init the Uploader with its dependent objects.
@param config Secor configuration
@param offsetTracker Tracker of the current offset of topics partitions
@param fileRegistry Registry of log files on a per-topic and per-partition basis
@param uploadManager Manager of the physical upload of log files to the remote reposit... | uploadFiles | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
protected FileReader createReader(LogFilePath srcPath, CompressionCodec codec) throws Exception {
return ReflectionUtil.createFileReader(
mConfig.getFileReaderWriterFactory(),
srcPath,
codec,
mConfig
);
} | This method is intended to be overwritten in tests.
@param srcPath source Path
@param codec compression codec
@return FileReader created file reader
@throws Exception on error | createReader | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
private void trim(LogFilePath srcPath, long startOffset) throws Exception {
final TopicPartition topicPartition = new TopicPartition(srcPath.getTopic(), srcPath.getKafkaPartition());
if (startOffset == srcPath.getOffset()) {
// If *all* the files had the right offset already, trimFiles would... | This method is intended to be overwritten in tests.
@param srcPath source Path
@param codec compression codec
@return FileReader created file reader
@throws Exception on error | trim | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
protected void trimFiles(TopicPartition topicPartition, long startOffset) throws Exception {
Collection<LogFilePath> paths = mFileRegistry.getPaths(topicPartition);
if (paths.stream().allMatch(srcPath -> srcPath.getOffset() == startOffset)) {
// We thought we needed to trim, but we were wron... | This method is intended to be overwritten in tests.
@param srcPath source Path
@param codec compression codec
@return FileReader created file reader
@throws Exception on error | trimFiles | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
private boolean isRequiredToUploadAtTime(TopicPartition topicPartition) throws Exception{
final String topic = topicPartition.getTopic();
if (mTopicFilter == null || mTopicFilter.isEmpty()){
return false;
}
if (topic.matches(mTopicFilter)){
if (DateTime.now().minu... | If the topic is in the list of topics to upload at a specific time. For example at a minute mark.
@param topicPartition
@return
@throws Exception | isRequiredToUploadAtTime | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
protected void checkTopicPartition(TopicPartition topicPartition, boolean forceUpload) throws Exception {
boolean shouldUpload;
if (mDeterministicUploadPolicyTracker != null) {
shouldUpload = mDeterministicUploadPolicyTracker.shouldUpload(topicPartition);
} else {
final l... | If the topic is in the list of topics to upload at a specific time. For example at a minute mark.
@param topicPartition
@return
@throws Exception | checkTopicPartition | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
private boolean activeFileCountExceeded(int fileCount) {
return mConfig.getMaxActiveFiles() > -1 && fileCount > mConfig.getMaxActiveFiles();
} | If the topic is in the list of topics to upload at a specific time. For example at a minute mark.
@param topicPartition
@return
@throws Exception | activeFileCountExceeded | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
private long getRemoteComittedOffsetCount(TopicPartition topicPartition) throws Exception {
//If storing offsets in Zookeeper is enabled we are going to always use those offsets.
if (isOffsetsStorageZookeeper) {
return mZookeeperConnector.getCommittedOffsetCount(topicPartition);
} el... | If the topic is in the list of topics to upload at a specific time. For example at a minute mark.
@param topicPartition
@return
@throws Exception | getRemoteComittedOffsetCount | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
public void applyPolicy(boolean forceUpload) throws Exception {
Collection<TopicPartition> topicPartitions = mFileRegistry.getTopicPartitions();
for (TopicPartition topicPartition : topicPartitions) {
checkTopicPartition(topicPartition, forceUpload);
}
} | Apply the Uploader policy for pushing partition files to the underlying storage.
For each of the partitions of the file registry, apply the policy for flushing
them to the underlying storage.
This method could be subclassed to provide an alternate policy. The custom uploader
class name would need to be specified in t... | applyPolicy | java | pinterest/secor | src/main/java/com/pinterest/secor/uploader/Uploader.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/uploader/Uploader.java | Apache-2.0 |
public int getCount() {
return count;
} | @author Luke Sun (luke.skywalker.sun@gmail.com) | getCount | java | pinterest/secor | src/main/java/com/pinterest/secor/util/BackOffUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/BackOffUtil.java | Apache-2.0 |
public long getLastBackOff() {
return lastBackOff;
} | @author Luke Sun (luke.skywalker.sun@gmail.com) | getLastBackOff | java | pinterest/secor | src/main/java/com/pinterest/secor/util/BackOffUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/BackOffUtil.java | Apache-2.0 |
public boolean isBackOff() {
count++;
if (count > lastBackOff) {
try {
lastBackOff = backOff.nextBackOffMillis();
} catch (IOException e) {
// we don't care IOException here
}
return false;
} else {
retur... | @author Luke Sun (luke.skywalker.sun@gmail.com) | isBackOff | java | pinterest/secor | src/main/java/com/pinterest/secor/util/BackOffUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/BackOffUtil.java | Apache-2.0 |
@Override
public void reset() {
interval = 0;
} | @author Luke Sun (luke.skywalker.sun@gmail.com) | reset | java | pinterest/secor | src/main/java/com/pinterest/secor/util/BackOffUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/BackOffUtil.java | Apache-2.0 |
@Override
public long nextBackOffMillis() {
if (interval < max) {
interval += inc;
if (interval < 0) {
interval = max;
}
return interval;
} else {
return max;
}
} | @author Luke Sun (luke.skywalker.sun@gmail.com) | nextBackOffMillis | java | pinterest/secor | src/main/java/com/pinterest/secor/util/BackOffUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/BackOffUtil.java | Apache-2.0 |
public static CompressionCodec createCompressionCodec(String className)
throws Exception {
Configuration configuration = new Configuration();
CompressionCodecFactory.setCodecClasses(configuration,new LinkedList<Class>(Collections.singletonList(Class.forName(className))));
Compression... | Compression Codec related helper methods
@author Praveen Murugesan (praveen@uber.com) | createCompressionCodec | java | pinterest/secor | src/main/java/com/pinterest/secor/util/CompressionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/CompressionUtil.java | Apache-2.0 |
public static void configure(SecorConfig config) {
if (config != null) {
if (config.getCloudService().equals("Swift")) {
mConf.set("fs.swift.impl", "org.apache.hadoop.fs.swift.snative.SwiftNativeFileSystem");
mConf.set("fs.swift.service.GENERICPROJECT.auth.url", confi... | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | configure | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static FileSystem getFileSystem(String path) throws IOException {
return FileSystem.get(URI.create(path), mConf);
} | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | getFileSystem | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static boolean s3PathPrefixIsAltered(String logFileName, SecorConfig config)
throws Exception {
Date logDate = null;
if (config.getS3AlterPathDate() != null && !config.getS3AlterPathDate().isEmpty()) {
Date s3AlterPathDate = new... | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | s3PathPrefixIsAltered | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static String getS3AlternativePathPrefix(SecorConfig config) {
return config.getS3AlternativePath();
} | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | getS3AlternativePathPrefix | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static String getS3AlternativePrefix(SecorConfig config) {
return config.getS3FileSystem() + "://" + config.getS3Bucket() + "/" + config.getS3AlternativePath();
} | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | getS3AlternativePrefix | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static String getPrefix(String topic, SecorConfig config) throws IOException {
String prefix = null;
if (config.getCloudService().equals("Swift")) {
String container = null;
if (config.getSeparateContainersForTopics()) {
if (!exists("swift://" + topic + ".... | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | getPrefix | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static String[] list(String path) throws IOException {
FileSystem fs = getFileSystem(path);
Path fsPath = new Path(path);
ArrayList<String> paths = new ArrayList<String>();
FileStatus[] statuses = fs.listStatus(fsPath);
if (statuses != null) {
for (FileStatus s... | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | list | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static String[] listRecursively(String path) throws IOException {
ArrayList<String> paths = new ArrayList<String>();
String[] directPaths = list(path);
for (String directPath : directPaths) {
if (directPath.equals(path)) {
assert directPaths.length == 1: Intege... | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | listRecursively | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static boolean exists(String path) throws IOException {
FileSystem fs = getFileSystem(path);
Path fsPath = new Path(path);
return fs.exists(fsPath);
} | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | exists | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static void delete(String path) throws IOException {
if (exists(path)) {
Path fsPath = new Path(path);
boolean success = getFileSystem(path).delete(fsPath, true); // recursive
if (!success) {
throw new IOException("Failed to delete " + path);
... | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | delete | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static void moveToCloud(String srcLocalPath, String dstCloudPath) throws IOException {
Path srcPath = new Path(srcLocalPath);
Path dstPath = new Path(dstCloudPath);
getFileSystem(dstCloudPath).moveFromLocalFile(srcPath, dstPath);
} | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | moveToCloud | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static void touch(String path) throws IOException {
FileSystem fs = getFileSystem(path);
Path fsPath = new Path(path);
fs.create(fsPath).close();
} | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | touch | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static long getModificationTimeMsRecursive(String path) throws IOException {
FileSystem fs = getFileSystem(path);
Path fsPath = new Path(path);
FileStatus status = fs.getFileStatus(fsPath);
long modificationTime = status.getModificationTime();
FileStatus[] statuses = fs.li... | File util implements utilities for interactions with the file system.
@author Pawel Garbacki (pawel@pinterest.com) | getModificationTimeMsRecursive | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static String getMd5Hash(String topic, String[] partitions) {
ArrayList<String> elements = new ArrayList<String>();
elements.add(topic);
for (String partition : partitions) {
elements.add(partition);
}
String pathPrefix = StringUtils.join(elements, "/");
try {
... | Generate MD5 hash of topic and partitions. And extract first 4 characters of the MD5 hash.
@param topic topic name
@param partitions partitions
@return md5 hash | getMd5Hash | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
private static String getHexEncode(byte[] bytes) {
final char[] chars = new char[bytes.length * 2];
for (int i = 0; i < bytes.length; ++i) {
final int cx = i * 2;
final byte b = bytes[i];
chars[cx] = m_digits[(b & 0xf0) >> 4];
chars[cx + 1] = m_digits[(b & 0x0f)];
}
... | Generate MD5 hash of topic and partitions. And extract first 4 characters of the MD5 hash.
@param topic topic name
@param partitions partitions
@return md5 hash | getHexEncode | java | pinterest/secor | src/main/java/com/pinterest/secor/util/FileUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/FileUtil.java | Apache-2.0 |
public static String getConsumerId() throws UnknownHostException {
String hostname = InetAddress.getLocalHost().getHostName();
String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
long threadId = Thread.currentThread().getId();
return hostname + "_" + pid + "_" + th... | Utilities related to identifiers.
@author Pawel Garbacki (pawel@pinterest.com) | getConsumerId | java | pinterest/secor | src/main/java/com/pinterest/secor/util/IdUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/IdUtil.java | Apache-2.0 |
public static String getLocalMessageDir() throws UnknownHostException {
String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
long threadId = Thread.currentThread().getId();
return pid + "_" + threadId;
} | Utilities related to identifiers.
@author Pawel Garbacki (pawel@pinterest.com) | getLocalMessageDir | java | pinterest/secor | src/main/java/com/pinterest/secor/util/IdUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/IdUtil.java | Apache-2.0 |
public boolean isConfigured() {
return allTopics || !messageClassByTopic.isEmpty();
} | @return whether there was a protobuf class configuration | isConfigured | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ProtobufUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ProtobufUtil.java | Apache-2.0 |
public Class<? extends Message> getMessageClass(String topic) {
return allTopics ? messageClassForAll : messageClassByTopic.get(topic);
} | Returns configured protobuf message class for the given Kafka topic
@param topic
Kafka topic
@return protobuf message class used by this utility instance, or
<code>null</code> in case valid class couldn't be found in the
configuration. | getMessageClass | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ProtobufUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ProtobufUtil.java | Apache-2.0 |
public Message decodeJsonMessage(String topic, byte[] payload) throws InvalidProtocolBufferException {
try {
Method builderGetter = allTopics ? messageClassForAll.getDeclaredMethod("newBuilder") : messageClassByTopic.get(topic).getDeclaredMethod("newBuilder");
com.google.protobuf.Generat... | Decodes protobuf message
@param topic
Kafka topic name
@param payload
Byte array containing encoded json message
@return protobuf message instance
@throws RuntimeException
when there's problem decoding protobuf message | decodeJsonMessage | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ProtobufUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ProtobufUtil.java | Apache-2.0 |
public Message decodeProtobufMessage(String topic, byte[] payload){
Method parseMethod = allTopics ? messageParseMethodForAll : messageParseMethodByTopic.get(topic);
try {
return (Message) parseMethod.invoke(null, payload);
} catch (IllegalArgumentException e) {
throw new... | Decodes protobuf message
@param topic
Kafka topic name
@param payload
Byte array containing encoded protobuf
@return protobuf message instance
@throws RuntimeException
when there's problem decoding protobuf | decodeProtobufMessage | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ProtobufUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ProtobufUtil.java | Apache-2.0 |
public Message decodeProtobufOrJsonMessage(String topic, byte[] payload) {
try {
if (shouldDecodeFromJsonMessage(topic)) {
return decodeJsonMessage(topic, payload);
}
} catch (InvalidProtocolBufferException e) {
//When trimming files, the Uploader will... | Decodes protobuf message
If the secor.topic.message.format property is set to "JSON" for "topic" assume "payload" is JSON
@param topic
Kafka topic name
@param payload
Byte array containing encoded protobuf or JSON message
@return protobuf message instance
@throws RuntimeException
when... | decodeProtobufOrJsonMessage | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ProtobufUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ProtobufUtil.java | Apache-2.0 |
private boolean shouldDecodeFromJsonMessage(String topic){
if (StringUtils.isNotEmpty(messageFormatForAll) && StringUtils.equalsIgnoreCase(messageFormatForAll, JSON)) {
return true;
} else if (StringUtils.equalsIgnoreCase(messageFormatByTopic.getOrDefault(topic, ""), JSON)) {
ret... | Decodes protobuf message
If the secor.topic.message.format property is set to "JSON" for "topic" assume "payload" is JSON
@param topic
Kafka topic name
@param payload
Byte array containing encoded protobuf or JSON message
@return protobuf message instance
@throws RuntimeException
when... | shouldDecodeFromJsonMessage | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ProtobufUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ProtobufUtil.java | Apache-2.0 |
public static UploadManager createUploadManager(String className,
SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!UploadManager.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(Strin... | Create an UploadManager from its fully qualified class name.
The class passed in by name must be assignable to UploadManager
and have 1-parameter constructor accepting a SecorConfig.
See the secor.upload.manager.class config option.
@param className The class name of a subclass of UploadManager
@param config The Sec... | createUploadManager | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ReflectionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ReflectionUtil.java | Apache-2.0 |
public static Uploader createUploader(String className) throws Exception {
Class<?> clazz = Class.forName(className);
if (!Uploader.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(String.format("The class '%s' is not assignable to '%s'.",
className, Up... | Create an Uploader from its fully qualified class name.
The class passed in by name must be assignable to Uploader.
See the secor.upload.class config option.
@param className The class name of a subclass of Uploader
@return an UploadManager instance with the runtime type of the class passed by name
@throws Except... | createUploader | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ReflectionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ReflectionUtil.java | Apache-2.0 |
public static MessageParser createMessageParser(String className,
SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!MessageParser.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(Strin... | Create a MessageParser from it's fully qualified class name.
The class passed in by name must be assignable to MessageParser and have 1-parameter constructor accepting a SecorConfig.
Allows the MessageParser to be pluggable by providing the class name of a desired MessageParser in config.
See the secor.message.parser.... | createMessageParser | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ReflectionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ReflectionUtil.java | Apache-2.0 |
private static FileReaderWriterFactory createFileReaderWriterFactory(String className,
SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!FileReaderWriterFactory.class.isAssignableFrom(clazz)) {
... | Create a FileReaderWriterFactory that is able to read and write a specific type of output log file.
The class passed in by name must be assignable to FileReaderWriterFactory.
Allows for pluggable FileReader and FileWriter instances to be constructed for a particular type of log file.
See the secor.file.reader.writer.f... | createFileReaderWriterFactory | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ReflectionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ReflectionUtil.java | Apache-2.0 |
public static FileWriter createFileWriter(String className, LogFilePath logFilePath,
CompressionCodec codec,
SecorConfig config)
throws Exception {
return createFileReaderWriterFactory(className, config).Buil... | Use the FileReaderWriterFactory specified by className to build a FileWriter
@param className the class name of a subclass of FileReaderWriterFactory to create a FileWriter from
@param logFilePath the LogFilePath that the returned FileWriter should write to
@param codec an instance CompressionCodec to compress the fil... | createFileWriter | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ReflectionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ReflectionUtil.java | Apache-2.0 |
public static FileReader createFileReader(String className, LogFilePath logFilePath,
CompressionCodec codec,
SecorConfig config)
throws Exception {
return createFileReaderWriterFactory(className, config).Buil... | Use the FileReaderWriterFactory specified by className to build a FileReader
@param className the class name of a subclass of FileReaderWriterFactory to create a FileReader from
@param logFilePath the LogFilePath that the returned FileReader should read from
@param codec an instance CompressionCodec to decompress the ... | createFileReader | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ReflectionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ReflectionUtil.java | Apache-2.0 |
public static MessageTransformer createMessageTransformer(
String className, SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!MessageTransformer.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(String.format(
... | Create a MessageTransformer from it's fully qualified class name. The
class passed in by name must be assignable to MessageTransformers and have
1-parameter constructor accepting a SecorConfig. Allows the MessageTransformers
to be pluggable by providing the class name of a desired MessageTransformers in
config.
See th... | createMessageTransformer | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ReflectionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ReflectionUtil.java | Apache-2.0 |
public static ORCSchemaProvider createORCSchemaProvider(
String className, SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!ORCSchemaProvider.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(String.format(
... | Create a ORCSchemaProvider from it's fully qualified class name. The
class passed in by name must be assignable to ORCSchemaProvider and have
1-parameter constructor accepting a SecorConfig. Allows the ORCSchemaProvider
to be pluggable by providing the class name of a desired ORCSchemaProvider in
config.
See the secor... | createORCSchemaProvider | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ReflectionUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ReflectionUtil.java | Apache-2.0 |
public static void setLabel(String name, String value) {
long threadId = Thread.currentThread().getId();
name += "." + threadId;
Stats.setLabel(name, value);
} | Utilities to interact with Ostrich stats exporter.
@author Pawel Garbacki (pawel@pinterest.com) | setLabel | java | pinterest/secor | src/main/java/com/pinterest/secor/util/StatsUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/StatsUtil.java | Apache-2.0 |
public static void clearLabel(String name) {
long threadId = Thread.currentThread().getId();
name += "." + threadId;
Stats.clearLabel(name);
} | Utilities to interact with Ostrich stats exporter.
@author Pawel Garbacki (pawel@pinterest.com) | clearLabel | java | pinterest/secor | src/main/java/com/pinterest/secor/util/StatsUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/StatsUtil.java | Apache-2.0 |
@SuppressWarnings("rawtypes")
public Class<? extends TBase> getMessageClass(String topic) {
return allTopics ? messageClassForAll : messageClassByTopic.get(topic);
} | Returns configured thrift message class for the given Kafka topic
@param topic
Kafka topic
@return thrift message class used by this utility instance, or
<code>null</code> in case valid class couldn't be found in the
configuration. | getMessageClass | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ThriftUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ThriftUtil.java | Apache-2.0 |
@SuppressWarnings("rawtypes")
public TBase decodeMessage(String topic, byte[] payload)
throws InstantiationException, IllegalAccessException, TException {
TDeserializer serializer = new TDeserializer(messageProtocolFactory);
TBase result = this.getMessageClass(topic).newInstance();
... | Returns configured thrift message class for the given Kafka topic
@param topic
Kafka topic
@return thrift message class used by this utility instance, or
<code>null</code> in case valid class couldn't be found in the
configuration. | decodeMessage | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ThriftUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ThriftUtil.java | Apache-2.0 |
@SuppressWarnings("rawtypes")
public byte[] encodeMessage(TBase object) throws InstantiationException,
IllegalAccessException, TException {
TSerializer serializer = new TSerializer(messageProtocolFactory);
return serializer.serialize(object);
} | Returns configured thrift message class for the given Kafka topic
@param topic
Kafka topic
@return thrift message class used by this utility instance, or
<code>null</code> in case valid class couldn't be found in the
configuration. | encodeMessage | java | pinterest/secor | src/main/java/com/pinterest/secor/util/ThriftUtil.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/ThriftUtil.java | Apache-2.0 |
public static void processRow(JSONWriter writer, VectorizedRowBatch batch,
TypeDescription schema, int row) throws JSONException {
if (schema.getCategory() == TypeDescription.Category.STRUCT) {
List<TypeDescription> fieldTypes = schema.getChildren();
List<String> fieldNames =... | @author Ashish (ashu.impetus@gmail.com) | processRow | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | Apache-2.0 |
static void setValue(JSONWriter writer, ColumnVector vector,
TypeDescription schema, int row) throws JSONException {
if (vector.isRepeating) {
row = 0;
}
if (vector.noNulls || !vector.isNull[row]) {
switch (schema.getCategory()) {
case BOOLEAN:
... | @author Ashish (ashu.impetus@gmail.com) | setValue | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | Apache-2.0 |
private static void setList(JSONWriter writer, ListColumnVector vector,
TypeDescription schema, int row) throws JSONException {
writer.array();
int offset = (int) vector.offsets[row];
TypeDescription childType = schema.getChildren().get(0);
for (int i = 0; i < vector.lengths[... | @author Ashish (ashu.impetus@gmail.com) | setList | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | Apache-2.0 |
private static void setStruct(JSONWriter writer, StructColumnVector batch,
TypeDescription schema, int row) throws JSONException {
writer.object();
List<String> fieldNames = schema.getFieldNames();
List<TypeDescription> fieldTypes = schema.getChildren();
for (int i = 0; i < f... | @author Ashish (ashu.impetus@gmail.com) | setStruct | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | Apache-2.0 |
private static void setMap(JSONWriter writer, MapColumnVector vector,
TypeDescription schema, int row) throws JSONException {
writer.object();
List<TypeDescription> schemaChildren = schema.getChildren();
BytesColumnVector keyVector = (BytesColumnVector) vector.keys... | @author Ashish (ashu.impetus@gmail.com) | setMap | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | Apache-2.0 |
private static void setUnion(JSONWriter writer, UnionColumnVector vector,
TypeDescription schema, int row) throws JSONException {
int tag = vector.tags[row];
List<TypeDescription> schemaChildren = schema.getChildren();
ColumnVector columnVector = vector.fields[ta... | Writes a single row of union type as a JSON object.
@throws JSONException | setUnion | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/JsonFieldFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
LongColumnVector vector = (LongColumnVector) vect;
vector.vector... | @author Ashish (ashu.impetus@gmail.com) | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
LongColumnVector vector = (LongColumnVector) vect;
vector.vector... | @author Ashish (ashu.impetus@gmail.com) | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
DoubleColumnVector vector = (DoubleColumnVector) vect;
vector.ve... | @author Ashish (ashu.impetus@gmail.com) | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
BytesColumnVector vector = (BytesColumnVector) vect;
byte[] byte... | @author Ashish (ashu.impetus@gmail.com) | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
BytesColumnVector vector = (BytesColumnVector) vect;
String binS... | @author Ashish (ashu.impetus@gmail.com) | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
if (value.getAsJsonPrimitive().isString()) {
TimestampColumn... | @author Ashish (ashu.impetus@gmail.com) | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
DecimalColumnVector vector = (DecimalColumnVector) vect;
vector.... | @author Ashish (ashu.impetus@gmail.com) | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
private JsonType getJsonType(TypeDescription.Category category) {
switch (category) {
case BOOLEAN:
return JsonType.BOOLEAN;
case BYTE:
case SHORT:
case INT:
case LONG:
case FLOAT:
... | Union type in ORC is essentially a collection of two or more non-compatible types,
and it is represented by multiple child columns under UnionColumnVector.
Thus we need converters for each type. | getJsonType | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
private JsonType getJsonType(JsonPrimitive value) {
if (value.isBoolean()) {
return JsonType.BOOLEAN;
} else if (value.isNumber()) {
return JsonType.NUMBER;
} else if (value.isString()) {
return JsonType.STRING;
} else {
... | Union type in ORC is essentially a collection of two or more non-compatible types,
and it is represented by multiple child columns under UnionColumnVector.
Thus we need converters for each type. | getJsonType | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else if (value.isJsonPrimitive()) {
UnionColumnVector vector = (UnionColumnVector) vect... | Union type in ORC is essentially a collection of two or more non-compatible types,
and it is represented by multiple child columns under UnionColumnVector.
Thus we need converters for each type. | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
StructColumnVector vector = (StructColumnVector) vect;
JsonObjec... | Union type in ORC is essentially a collection of two or more non-compatible types,
and it is represented by multiple child columns under UnionColumnVector.
Thus we need converters for each type. | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public void convert(JsonElement value, ColumnVector vect, int row) {
if (value == null || value.isJsonNull()) {
vect.noNulls = false;
vect.isNull[row] = true;
} else {
ListColumnVector vector = (ListColumnVector) vect;
JsonArray obj... | Union type in ORC is essentially a collection of two or more non-compatible types,
and it is represented by multiple child columns under UnionColumnVector.
Thus we need converters for each type. | convert | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public static JsonConverter createConverter(TypeDescription schema) {
switch (schema.getCategory()) {
case BYTE:
case SHORT:
case INT:
case LONG:
return new LongColumnConverter();
case FLOAT:
case DOUBLE:
return new DoubleColumnConverter();... | Union type in ORC is essentially a collection of two or more non-compatible types,
and it is represented by multiple child columns under UnionColumnVector.
Thus we need converters for each type. | createConverter | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
public static void fillRow(int rowIndex, JsonConverter[] converters,
TypeDescription schema, VectorizedRowBatch batch, JsonObject data) {
List<String> fieldNames = schema.getFieldNames();
for (int c = 0; c < converters.length; ++c) {
JsonElement field = data.get(fieldNames.get(c)... | Union type in ORC is essentially a collection of two or more non-compatible types,
and it is represented by multiple child columns under UnionColumnVector.
Thus we need converters for each type. | fillRow | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/VectorColumnFiller.java | Apache-2.0 |
@Override
public TypeDescription getSchema(String topic, LogFilePath logFilePath) {
TypeDescription topicSpecificTD = topicToSchemaMap.get(topic);
if (null != topicSpecificTD) {
return topicSpecificTD;
}
return schemaForAlltopic;
} | Default implementation for ORC schema provider. It fetches ORC schemas from
configuration. User has to specify one schema per kafka topic or can have
same schema for all the topics.
@author Ashish (ashu.impetus@gmail.com) | getSchema | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/schema/DefaultORCSchemaProvider.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/schema/DefaultORCSchemaProvider.java | Apache-2.0 |
private void setSchemas(SecorConfig config) {
Map<String, String> schemaPerTopic = config.getORCMessageSchema();
for (Entry<String, String> entry : schemaPerTopic.entrySet()) {
String topic = entry.getKey();
TypeDescription schema = TypeDescription.fromString(entry
... | This method is used for fetching all ORC schemas from config
@param config | setSchemas | java | pinterest/secor | src/main/java/com/pinterest/secor/util/orc/schema/DefaultORCSchemaProvider.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/util/orc/schema/DefaultORCSchemaProvider.java | Apache-2.0 |
public void adjustOffset(Message message, boolean isLegacyConsumer) throws IOException {
TopicPartition topicPartition = new TopicPartition(message.getTopic(),
message.getKafkaPartition());
long lastSeenOffset = mOffsetTracker.getLastSeenOffset(... | Message writer appends Kafka messages to local log files.
@author Pawel Garbacki (pawel@pinterest.com) | adjustOffset | java | pinterest/secor | src/main/java/com/pinterest/secor/writer/MessageWriter.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/writer/MessageWriter.java | Apache-2.0 |
public void write(ParsedMessage message) throws Exception {
TopicPartition topicPartition = new TopicPartition(message.getTopic(),
message.getKafkaPartition());
long offset = mOffsetTracker.getAdjustedCommittedOffsetCount(topicPartition);
... | Message writer appends Kafka messages to local log files.
@author Pawel Garbacki (pawel@pinterest.com) | write | java | pinterest/secor | src/main/java/com/pinterest/secor/writer/MessageWriter.java | https://github.com/pinterest/secor/blob/master/src/main/java/com/pinterest/secor/writer/MessageWriter.java | Apache-2.0 |
public void setUp() throws Exception {
super.setUp();
PropertiesConfiguration properties = new PropertiesConfiguration();
properties.addProperty("secor.file.reader.writer.factory",
"com.pinterest.secor.io.impl.SequenceFileReaderWriterFactory");
properties.addProperty("sec... | FileRegistryTest tests the file registry logic.
@author Pawel Garbacki (pawel@pinterest.com) | setUp | java | pinterest/secor | src/test/java/com/pinterest/secor/common/FileRegistryTest.java | https://github.com/pinterest/secor/blob/master/src/test/java/com/pinterest/secor/common/FileRegistryTest.java | Apache-2.0 |
private FileWriter createWriter() throws Exception {
PowerMockito.mockStatic(FileUtil.class);
PowerMockito.mockStatic(ReflectionUtil.class);
FileWriter writer = Mockito.mock(FileWriter.class);
Mockito.when(
ReflectionUtil.createFileWriter(
Mockito... | FileRegistryTest tests the file registry logic.
@author Pawel Garbacki (pawel@pinterest.com) | createWriter | java | pinterest/secor | src/test/java/com/pinterest/secor/common/FileRegistryTest.java | https://github.com/pinterest/secor/blob/master/src/test/java/com/pinterest/secor/common/FileRegistryTest.java | Apache-2.0 |
public void testGetOrCreateWriter() throws Exception {
createWriter();
// Call the method again. This time it should return an existing writer.
mRegistry.getOrCreateWriter(mLogFilePath, null);
// Verify that the method has been called exactly once (the default).
PowerMockito.ve... | FileRegistryTest tests the file registry logic.
@author Pawel Garbacki (pawel@pinterest.com) | testGetOrCreateWriter | java | pinterest/secor | src/test/java/com/pinterest/secor/common/FileRegistryTest.java | https://github.com/pinterest/secor/blob/master/src/test/java/com/pinterest/secor/common/FileRegistryTest.java | Apache-2.0 |
public void testGetWriterShowBeNotNull() throws Exception {
FileWriter createdWriter = createWriter();
FileWriter writer = mRegistry.getWriter(mLogFilePath);
assertNotNull(writer);
assertEquals(createdWriter, writer);
} | FileRegistryTest tests the file registry logic.
@author Pawel Garbacki (pawel@pinterest.com) | testGetWriterShowBeNotNull | java | pinterest/secor | src/test/java/com/pinterest/secor/common/FileRegistryTest.java | https://github.com/pinterest/secor/blob/master/src/test/java/com/pinterest/secor/common/FileRegistryTest.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.