Return-Path: X-Original-To: apmail-streams-commits-archive@minotaur.apache.org Delivered-To: apmail-streams-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0B06310C50 for ; Thu, 9 Jan 2014 17:30:33 +0000 (UTC) Received: (qmail 5079 invoked by uid 500); 9 Jan 2014 17:29:34 -0000 Delivered-To: apmail-streams-commits-archive@streams.apache.org Received: (qmail 4974 invoked by uid 500); 9 Jan 2014 17:29:28 -0000 Mailing-List: contact commits-help@streams.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@streams.incubator.apache.org Delivered-To: mailing list commits@streams.incubator.apache.org Received: (qmail 4808 invoked by uid 99); 9 Jan 2014 17:29:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jan 2014 17:29:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jan 2014 17:29:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 003A22388C9C; Thu, 9 Jan 2014 17:28:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1556893 [25/25] - in /incubator/streams/branches/sblackmon: ./ streams-config-graph/ streams-config-graph/src/ streams-config-graph/src/main/ streams-config-graph/src/main/java/ streams-config-graph/src/main/java/org/ streams-config-graph/... Date: Thu, 09 Jan 2014 17:27:58 -0000 To: commits@streams.incubator.apache.org From: sblackmon@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140109172809.003A22388C9C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/make-friend.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/make-friend.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/make-friend.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/make-friend.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Befriend", + "description" : "To friend an object. Usually a person", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "make-friend" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} is now friends with {object.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/play.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/play.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/play.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/play.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Play", + "description" : "To play an object", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "play" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} played {object.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/post.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/post.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/post.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/post.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Post", + "description" : "To publish an object", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "post" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} posted {object.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-maybe.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-maybe.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-maybe.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-maybe.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Rsvp Maybe", + "description" : "To indicate that the actor may attend an event", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "rsvp-maybe" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} may be attending {object.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-no.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-no.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-no.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-no.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Rsvp No", + "description" : "To indicate that the actor will not attend an event", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "rsvp-no" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} will not attend {object.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-yes.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-yes.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-yes.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/rsvp-yes.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Rsvp Yes", + "description" : "To indicate that the actor will attend an event", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "rsvp-yes" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} is attending {object.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/save.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/save.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/save.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/save.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Save", + "description" : "To save an object", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "save" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} saved {object.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/share.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/share.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/share.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/share.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Share", + "description" : "To share an object.", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "share" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} shared {object.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/tag.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/tag.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/tag.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/tag.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,16 @@ +{ + "type" : "object", + "title" : "Tag", + "description" : "To tag an object. Ex: A person being tagged in a photo", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "tag" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} tagged {object.displayName} in {target.displayName}" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/update.json URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/update.json?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/update.json (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/jsonschema/org/apache/streams/pojo/json/verbs/update.json Thu Jan 9 17:27:50 2014 @@ -0,0 +1,26 @@ +{ + "type" : "object", + "title" : "Update", + "description" : "To update a property on an object. Ex: Monica updated her street address to 234 Awesome St.", + "notes" : "The new property value can be a scalar value or an object. See the property object type", + "extends": {"$ref":"../activity.json"}, + "properties" :{ + "verb" :{ + "type" : "string", + "default" : "update" + }, + "title" : { + "type" : "string", + "default" : "{actor.displayName} updated {target.displayName}'s {object.displayName} to {object.value}" + }, + "object" : { + "type" : "object", + "$ref" : "../object.json" + }, + "target" : { + "type" : "object", + "optional" : true, + "$ref" : "../object.json" + } + } +} Added: incubator/streams/branches/sblackmon/streams-pojo/src/main/xmlschema/org/apache/streams/pojo/xml/activity.xsd URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/main/xmlschema/org/apache/streams/pojo/xml/activity.xsd?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/main/xmlschema/org/apache/streams/pojo/xml/activity.xsd (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/main/xmlschema/org/apache/streams/pojo/xml/activity.xsd Thu Jan 9 17:27:50 2014 @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Added: incubator/streams/branches/sblackmon/streams-pojo/src/test/java/org/apache/streams/data/data/util/JsonUtilTest.java URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-pojo/src/test/java/org/apache/streams/data/data/util/JsonUtilTest.java?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-pojo/src/test/java/org/apache/streams/data/data/util/JsonUtilTest.java (added) +++ incubator/streams/branches/sblackmon/streams-pojo/src/test/java/org/apache/streams/data/data/util/JsonUtilTest.java Thu Jan 9 17:27:50 2014 @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.streams.data.data.util; + + +import org.junit.Ignore; +import org.junit.Test; + +public class JsonUtilTest { + + @Ignore @Test + public void testJsonToObject(){ + } + +} Added: incubator/streams/branches/sblackmon/streams-storm/pom.xml URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-storm/pom.xml?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-storm/pom.xml (added) +++ incubator/streams/branches/sblackmon/streams-storm/pom.xml Thu Jan 9 17:27:50 2014 @@ -0,0 +1,98 @@ + + + + + + streams-project + org.apache.streams + 0.1-SNAPSHOT + + 4.0.0 + streams-storm + + + + org.apache.streams + streams-config + 0.1-SNAPSHOT + + + org.apache.streams + streams-config-graph + 0.1-SNAPSHOT + + + org.apache.streams + streams-util + 0.1-SNAPSHOT + + + org.apache.commons + commons-lang3 + + + storm + storm-core + + + storm + storm-netty + + + org.scala-lang + scala-library + 2.9.2 + compile + jar + + + com.101tec + zkclient + 0.2 + compile + + + log4j + log4j + + + org.slf4j + slf4j-log4j12 + + + + + + + src/main/java + src/test/java + + + src/main/resources + + + + + src/test/resources + + + + Added: incubator/streams/branches/sblackmon/streams-storm/src/main/java/org/apache/streams/storm/PipelineGraphLauncher.java URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-storm/src/main/java/org/apache/streams/storm/PipelineGraphLauncher.java?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-storm/src/main/java/org/apache/streams/storm/PipelineGraphLauncher.java (added) +++ incubator/streams/branches/sblackmon/streams-storm/src/main/java/org/apache/streams/storm/PipelineGraphLauncher.java Thu Jan 9 17:27:50 2014 @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.streams.storm; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.typesafe.config.Config; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.streams.config.StreamsConfigurator; +import org.apache.streams.util.RegexUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA. + * User: sblackmon + * Date: 9/20/13 + * Time: 11:17 AM + * To change this template use File | Settings | File Templates. + */ +public class PipelineGraphLauncher { + + private static final Logger log = LoggerFactory.getLogger(PipelineGraphLauncher.class); + + private static Config streamsConfiguration; + + private static List> topologies; + + private static List> resolveClasses(List> topologyPairs) throws IOException, ClassNotFoundException { + + List> topologies = new ArrayList>(); + + for( Pair pair : topologyPairs ) { + String topologyId = pair.getLeft(); + Class topologyClass = Class.forName(pair.getRight()); + topologies.add(new ImmutablePair(topologyId, topologyClass)); + } + + return topologies; + } + + private static List> loadTopologiesFromPipelineTopologyListFile(File file) throws IOException, ClassNotFoundException { + + List lines = IOUtils.readLines(FileUtils.openInputStream(file)); + String pattern = "^([\\w-]*)[\\s]*?([\\w.]*)$"; + + List> topologyPairs = RegexUtils.getTwoMatchedGroupsList(lines, pattern); + + topologies = resolveClasses(topologyPairs); + + for( Pair pair : topologyPairs ) { + String topologyId = pair.getLeft(); + Class topologyClass = Class.forName(pair.getRight()); + topologies.add(new ImmutablePair(topologyId, topologyClass)); + } + + return topologies; + } + + private static List> loadTopologiesFromPipelineGraphFile(File file) throws IOException, ClassNotFoundException { + + List lines = IOUtils.readLines(FileUtils.openInputStream(file)); + String pattern = "$([\\w-]*)\\s([\\w.)"; + + List> topologyPairs = RegexUtils.getTwoMatchedGroupsList(lines, pattern); + + topologies = resolveClasses(topologyPairs); + + return topologies; + } + + public static boolean isLocal(String[] args) { + if(args.length >= 1 && args[1].equals("deploy")) + return false; + else return true; + } + + public static void main(String[] args) throws Exception { + + if(args.length < 3) { + log.error("Not enough arguments"); + log.error(" storm {local,deploy} "); + return; + } + if(!args[1].equals("deploy")) { + log.error("Not a deploy"); + log.error(" storm {local,deploy} "); + return; + } + + ObjectMapper mapper = new ObjectMapper(); + + URL configFileUrl = PipelineGraphLauncher.class.getResource(args[0]); + + File configFile; + try { + configFile = new File(configFileUrl.toURI()); + } catch(URISyntaxException e) { + configFile = new File(configFileUrl.getPath()); + } + + streamsConfiguration = StreamsConfigurator.config; + +// String pipelineIdentifier = streamsConfiguration.getPipeline(); +// +// for( Map.Entry moduleConfig : streamsConfiguration.getAdditionalProperties().entrySet()) { +// +// } + +// each defined graph becomes a topology + +// +// URL pipelineFileUrl = PipelineGraphLauncher.class.getResource(args[1]); +// +// File pipelineFile; +// try { +// pipelineFile = new File(pipelineFileUrl.toURI()); +// } catch(URISyntaxException e) { +// pipelineFile = new File(pipelineFileUrl.getPath()); +// } +// +// topologies = loadTopologiesFromPipelineTopologyListFile(pipelineFile); +// +// for( Pair topology : topologies ) { +// Class topologyClass = topology.getRight(); +// +// try { +// Constructor ctor = topologyClass.getDeclaredConstructor( +// String.class, +// StreamsConfiguration.class); +// ctor.setAccessible(true); +// Object topologyObject = ctor.newInstance(pipelineIdentifier, streamsConfiguration); +// Runnable runnable = (Runnable) topologyObject; +// runnable.run(); +// } catch (InstantiationException x) { +// log.warn(x.getMessage()); +// x.printStackTrace(); +// } catch (IllegalAccessException x) { +// log.warn(x.getMessage()); +// x.printStackTrace(); +// } catch (InvocationTargetException x) { +// log.warn(x.getMessage()); +// x.printStackTrace(); +// } catch (NoSuchMethodException x) { +// log.warn(x.getMessage()); +// x.printStackTrace(); +// +// try { +// Constructor ctor = topologyClass.getDeclaredConstructor( +// String[].class); +// ctor.setAccessible(true); +// Object topologyObject = ctor.newInstance(args); +// Method main = topologyClass.getMethod("main", String[].class); +// main.invoke(topologyObject, args); +// } catch (InstantiationException x2) { +// log.warn(x2.getMessage()); +// x.printStackTrace(); +// } catch (IllegalAccessException x2) { +// log.warn(x2.getMessage()); +// x.printStackTrace(); +// } catch (InvocationTargetException x2) { +// log.warn(x2.getMessage()); +// x.printStackTrace(); +// } catch (NoSuchMethodException x2) { +// log.error(x2.getMessage()); +// x.printStackTrace(); +// } +// } +// } + } +} Added: incubator/streams/branches/sblackmon/streams-storm/src/main/java/org/apache/streams/storm/trident/StreamsTopology.java URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-storm/src/main/java/org/apache/streams/storm/trident/StreamsTopology.java?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-storm/src/main/java/org/apache/streams/storm/trident/StreamsTopology.java (added) +++ incubator/streams/branches/sblackmon/streams-storm/src/main/java/org/apache/streams/storm/trident/StreamsTopology.java Thu Jan 9 17:27:50 2014 @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.streams.storm.trident; + +import backtype.storm.Config; +import org.apache.streams.StreamsConfiguration; +import org.apache.streams.config.StreamsConfigurator; +import storm.trident.TridentTopology; + +/** + * Created with IntelliJ IDEA. + * User: sblackmon + * Date: 9/20/13 + * Time: 5:48 PM + * To change this template use File | Settings | File Templates. + */ +public abstract class StreamsTopology extends TridentTopology { + + StreamsConfiguration configuration; + Config stormConfig; + String runmode; + + protected StreamsTopology() { + + runmode = StreamsConfigurator.config.getConfig("storm").getString("runmode"); + stormConfig = new Config(); + + } + + protected StreamsTopology(StreamsConfiguration configuration) { + this.configuration = configuration; + } + + public StreamsConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration(StreamsConfiguration configuration) { + this.configuration = configuration; + } + + public String getRunmode() { + return runmode; + } + + public void setRunmode(String runmode) { + this.runmode = runmode; + } + + public Config getStormConfig() { + return stormConfig; + } + + public void setStormConfig(Config stormConfig) { + this.stormConfig = stormConfig; + } +} Added: incubator/streams/branches/sblackmon/streams-util/pom.xml URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-util/pom.xml?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-util/pom.xml (added) +++ incubator/streams/branches/sblackmon/streams-util/pom.xml Thu Jan 9 17:27:50 2014 @@ -0,0 +1,44 @@ + + + + + + streams-project + org.apache.streams + 0.1-SNAPSHOT + + 4.0.0 + + streams-util + jar + + + + org.apache.commons + commons-lang3 + + + com.google.guava + guava + + + + \ No newline at end of file Added: incubator/streams/branches/sblackmon/streams-util/src/main/java/org/apache/streams/util/GuidUtils.java URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-util/src/main/java/org/apache/streams/util/GuidUtils.java?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-util/src/main/java/org/apache/streams/util/GuidUtils.java (added) +++ incubator/streams/branches/sblackmon/streams-util/src/main/java/org/apache/streams/util/GuidUtils.java Thu Jan 9 17:27:50 2014 @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.streams.util; + +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; +import com.google.common.hash.Hashing; + +import java.nio.charset.Charset; + +/** + * Created by sblackmon on 12/13/13. + */ +public class GuidUtils { + + private static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); + + public static String generateGuid(String... parts) { + + StringBuilder seed = new StringBuilder(); + for( String part : parts ) { + Preconditions.checkNotNull(part); + Preconditions.checkArgument(!Strings.isNullOrEmpty(part)); + seed.append(part); + } + + String hash = Hashing.goodFastHash(24).hashString(seed, UTF8_CHARSET).asBytes().toString(); + + return hash; + + } +} Added: incubator/streams/branches/sblackmon/streams-util/src/main/java/org/apache/streams/util/RegexUtils.java URL: http://svn.apache.org/viewvc/incubator/streams/branches/sblackmon/streams-util/src/main/java/org/apache/streams/util/RegexUtils.java?rev=1556893&view=auto ============================================================================== --- incubator/streams/branches/sblackmon/streams-util/src/main/java/org/apache/streams/util/RegexUtils.java (added) +++ incubator/streams/branches/sblackmon/streams-util/src/main/java/org/apache/streams/util/RegexUtils.java Thu Jan 9 17:27:50 2014 @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.streams.util; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + +public class RegexUtils { + + public static boolean matches(String line, String regEx) { + + boolean regExpMatches = false; + + if (StringUtils.isNotBlank(line) && StringUtils.isNotBlank(regEx)) { + if (line.matches(regEx)) { + regExpMatches = true; + } + } + return regExpMatches; + } + + public static List getMatches(String line, String regEx, int group){ + Pattern pattern = Pattern.compile(regEx); + Matcher matcher = pattern.matcher(line); + List matches = new ArrayList(); + + while (matcher.find()) { + + matches.add(matcher.group(group)); + } + + return matches; + } + + public static List> getTwoMatchedGroupsList(List lines, String regEx){ + List> matches = new ArrayList>(); + + for( String line : lines ) { + + Pair match = getTwoMatchedGroups(line, regEx); + if( match != null ) + matches.add(match); + + } + return matches; + } + + public static Pair getTwoMatchedGroups(String line, String regEx){ + Pattern pattern = Pattern.compile(regEx); + Matcher matcher = pattern.matcher(line); + Pair match = null; + + while (matcher.find()) { + Pair pair = new ImmutablePair(matcher.group(0), matcher.group(1)); + match = pair; + } + + return match; + } + + public static String getMatchedContent(String line, String regEx){ + Pattern pattern = Pattern.compile(regEx); + Matcher matcher = pattern.matcher(line); + String matchedContent = null; + if (matcher.find()) { + matchedContent = matcher.group(); + } + + return matchedContent; + } +}