streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject svn commit: r1557615 - in /incubator/streams/branches/sblackmon/streams-contrib: streams-persist-console/ streams-persist-console/src/main/java/org/apache/streams/console/ streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/
Date Sun, 12 Jan 2014 21:49:36 GMT
Author: sblackmon
Date: Sun Jan 12 21:49:35 2014
New Revision: 1557615

URL: http://svn.apache.org/r1557615
Log:
a few missing files

Added:
    incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/pom.xml
    incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/src/main/java/org/apache/streams/console/ConsolePersistWriter.java
    incubator/streams/branches/sblackmon/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProviderTask.java

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/pom.xml
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/pom.xml?rev=1557615&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/pom.xml (added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/pom.xml Sun
Jan 12 21:49:35 2014
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>streams-contrib</artifactId>
+        <groupId>org.apache.streams</groupId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>streams-persist-console</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.streams</groupId>
+            <artifactId>streams-core</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.streams</groupId>
+            <artifactId>streams-pojo</artifactId>
+            <version>0.1-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/src/main/java/org/apache/streams/console/ConsolePersistWriter.java
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/src/main/java/org/apache/streams/console/ConsolePersistWriter.java?rev=1557615&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/src/main/java/org/apache/streams/console/ConsolePersistWriter.java
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-persist-console/src/main/java/org/apache/streams/console/ConsolePersistWriter.java
Sun Jan 12 21:49:35 2014
@@ -0,0 +1,64 @@
+package org.apache.streams.console;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.streams.core.StreamsDatum;
+import org.apache.streams.core.StreamsPersistWriter;
+import org.apache.streams.core.StreamsResultSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Queue;
+import java.util.Random;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class ConsolePersistWriter implements StreamsPersistWriter {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConsolePersistWriter.class);
+
+    protected volatile Queue<StreamsDatum> persistQueue = new ConcurrentLinkedQueue<StreamsDatum>();
+
+    private ObjectMapper mapper = new ObjectMapper();
+
+    public ConsolePersistWriter(Queue<StreamsDatum> persistQueue) {
+        this.persistQueue = persistQueue;
+    }
+
+    @Override
+    public void start() {
+        new Thread(new ConsolePersistWriterTask(this)).start();
+    }
+
+    @Override
+    public void stop() {
+
+    }
+
+    @Override
+    public void setPersistQueue(Queue<StreamsDatum> persistQueue) {
+        this.persistQueue = persistQueue;
+    }
+
+    @Override
+    public Queue<StreamsDatum> getPersistQueue() {
+        return this.persistQueue;
+    }
+
+    @Override
+    public void write(StreamsDatum entry) {
+
+        try {
+
+            String text = mapper.writeValueAsString(entry);
+
+            System.out.println(text);
+
+        } catch (JsonProcessingException e) {
+            LOGGER.warn("save: {}", e);
+        }
+
+    }
+
+}

Added: incubator/streams/branches/sblackmon/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProviderTask.java
URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProviderTask.java?rev=1557615&view=auto
==============================================================================
--- incubator/streams/branches/sblackmon/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProviderTask.java
(added)
+++ incubator/streams/branches/sblackmon/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterStreamProviderTask.java
Sun Jan 12 21:49:35 2014
@@ -0,0 +1,53 @@
+package org.apache.streams.twitter.provider;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.twitter.hbc.ClientBuilder;
+import com.twitter.hbc.core.Constants;
+import com.twitter.hbc.core.endpoint.StatusesFirehoseEndpoint;
+import com.twitter.hbc.core.endpoint.StatusesSampleEndpoint;
+import com.twitter.hbc.core.endpoint.StreamingEndpoint;
+import com.twitter.hbc.core.processor.StringDelimitedProcessor;
+import com.twitter.hbc.httpclient.BasicClient;
+import com.twitter.hbc.httpclient.auth.Authentication;
+import com.twitter.hbc.httpclient.auth.OAuth1;
+import com.typesafe.config.Config;
+import org.apache.streams.config.StreamsConfigurator;
+import org.apache.streams.core.StreamsDatum;
+import org.apache.streams.core.StreamsProvider;
+import org.apache.streams.core.StreamsResultSet;
+import org.apache.streams.twitter.TwitterStreamConfiguration;
+import org.joda.time.DateTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.List;
+import java.util.Queue;
+import java.util.concurrent.*;
+
+/**
+ * Created by sblackmon on 12/10/13.
+ */
+public class TwitterStreamProviderTask implements Runnable {
+
+    private final static Logger LOGGER = LoggerFactory.getLogger(TwitterStreamProviderTask.class);
+
+    private TwitterStreamProvider provider;
+
+    public TwitterStreamProviderTask(TwitterStreamProvider provider) {
+        this.provider = provider;
+    }
+
+    @Override
+    public void run() {
+
+        provider.client.connect();
+
+    }
+
+}



Mime
View raw message