Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added scribe spout

  • Loading branch information...
commit 9fe2ca258eca5f61175392bee3e4b92f8b106ab7 1 parent a8d99c0
@nathanmarz authored
View
3  .gitignore
@@ -1 +1,4 @@
.lein-deps-sum
+classes/
+lib/
+*.jar
View
7 storm-scribe/README
@@ -0,0 +1,7 @@
+This is an implementation of a spout that receives data from Scribe. It is an example of a "push spout", in that data is pushed to it rather than the spout pulling data from somewhere else.
+
+This spout requires a fork of Scribe that allows for Zookeeper-based node discovery: https://github.com/traviscrawford/scribe
+
+See http://groups.google.com/group/scribe-server/msg/c6d04c3b0ee25ddc for more details on how that works.
+
+This is an unreliable spout that doesn't guarantee data processing. With some more work, it can be extended to be reliable – see the note in ScribeReceiver.java.
View
6 storm-scribe/gen.sh
@@ -0,0 +1,6 @@
+rm -rf gen-javabean src/jvm/storm/scribe/generated
+thrift7 -r --gen java:beans,hashcode,nocamel src/scribe.thrift
+mv gen-javabean/storm/scribe/generated src/jvm/storm/scribe/
+rm -rf gen-javabean
+
+
View
11 storm-scribe/project.clj
@@ -0,0 +1,11 @@
+(defproject storm/storm-scribe "0.0.1-SNAPSHOT"
+ :description "Spout implementation for scribe"
+ :source-path "src/clj"
+ :java-source-path "src/jvm"
+ :javac-options {:debug "true" :fork "true"}
+ :resources-path "config"
+ :dependencies []
+ :dev-dependencies [[storm "0.7.1-SNAPSHOT"]
+ [org.clojure/clojure "1.2.1"]
+ [org.clojure/clojure-contrib "1.2.0"]
+ ])
View
110 storm-scribe/src/fb303/if/fb303.thrift
@@ -0,0 +1,110 @@
+/*
+ * 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
+ * with the License. You may obtain a copy of the License at
+ *
+ * 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.
+ */
+
+/**
+ * fb303.thrift
+ */
+
+namespace java storm.scribe.generated
+
+/**
+ * Common status reporting mechanism across all services
+ */
+enum fb_status {
+ DEAD = 0,
+ STARTING = 1,
+ ALIVE = 2,
+ STOPPING = 3,
+ STOPPED = 4,
+ WARNING = 5,
+}
+
+/**
+ * Standard base service
+ */
+service FacebookService {
+
+ /**
+ * Returns a descriptive name of the service
+ */
+ string getName(),
+
+ /**
+ * Returns the version of the service
+ */
+ string getVersion(),
+
+ /**
+ * Gets the status of this service
+ */
+ fb_status getStatus(),
+
+ /**
+ * User friendly description of status, such as why the service is in
+ * the dead or warning state, or what is being started or stopped.
+ */
+ string getStatusDetails(),
+
+ /**
+ * Gets the counters for this service
+ */
+ map<string, i64> getCounters(),
+
+ /**
+ * Gets the value of a single counter
+ */
+ i64 getCounter(1: string key),
+
+ /**
+ * Sets an option
+ */
+ void setOption(1: string key, 2: string value),
+
+ /**
+ * Gets an option
+ */
+ string getOption(1: string key),
+
+ /**
+ * Gets all options
+ */
+ map<string, string> getOptions(),
+
+ /**
+ * Returns a CPU profile over the given time interval (client and server
+ * must agree on the profile format).
+ */
+ string getCpuProfile(1: i32 profileDurationInSec),
+
+ /**
+ * Returns the unix time that the server has been running since
+ */
+ i64 aliveSince(),
+
+ /**
+ * Tell the server to reload its configuration, reopen log files, etc
+ */
+ oneway void reinitialize(),
+
+ /**
+ * Suggest a shutdown to the server
+ */
+ oneway void shutdown(),
+
+}
View
97 storm-scribe/src/jvm/storm/scribe/BatchScribeSpout.java
@@ -0,0 +1,97 @@
+package storm.scribe;
+
+import backtype.storm.spout.RawScheme;
+import backtype.storm.spout.Scheme;
+import backtype.storm.coordination.BatchOutputCollector;
+import backtype.storm.task.TopologyContext;
+import backtype.storm.topology.OutputFieldsDeclarer;
+import backtype.storm.topology.base.BaseTransactionalSpout;
+import backtype.storm.transactional.ITransactionalSpout.Coordinator;
+import backtype.storm.transactional.TransactionAttempt;
+import backtype.storm.tuple.Fields;
+import backtype.storm.tuple.Values;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.LinkedList;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class BatchScribeSpout extends BaseTransactionalSpout {
+ public class ScribeCoordinator implements Coordinator {
+ @Override
+ public Object initializeTransaction(BigInteger txid, Object lastMeta) {
+ return null;
+ }
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public boolean isReady() {
+ return true;
+ }
+ }
+
+ public class ScribeEmitter implements Emitter {
+ LinkedBlockingQueue<byte[]> _events;
+ ScribeReceiver _receiver;
+ List<byte[]> _buffer;
+
+ public ScribeEmitter(Map conf, TopologyContext context) {
+ _events = ScribeReceiver.makeEventsQueue(conf);
+ _buffer = new ArrayList<byte[]>();
+ _receiver = new ScribeReceiver(_events, conf, context, _zkStr, _zkRoot);
+ }
+
+ @Override
+ public void emitBatch(TransactionAttempt tx, Object meta, BatchOutputCollector collector) {
+ _buffer.clear();
+ _events.drainTo(_buffer);
+ for(byte[] elem: _buffer) {
+ LinkedList<Object> values = new LinkedList<Object>(_scheme.deserialize(elem));
+ values.addFirst(tx);
+ collector.emit(values);
+ }
+ }
+
+ @Override
+ public void cleanupBefore(BigInteger txid) {
+ }
+
+ @Override
+ public void close() {
+ }
+
+ }
+
+ String _zkStr;
+ String _zkRoot;
+ Scheme _scheme;
+
+ public BatchScribeSpout(String zkStr, String zkRoot, Scheme scheme) {
+ _zkStr = zkStr;
+ _zkRoot = zkRoot;
+ _scheme = scheme;
+ }
+
+ public BatchScribeSpout(String zkStr, String zkRoot) {
+ this(zkStr, zkRoot, new RawScheme());
+ }
+
+ @Override
+ public Coordinator getCoordinator(Map conf, TopologyContext context) {
+ return new ScribeCoordinator();
+ }
+
+ @Override
+ public Emitter getEmitter(Map conf, TopologyContext context) {
+ return new ScribeEmitter(conf, context);
+ }
+
+ @Override
+ public void declareOutputFields(OutputFieldsDeclarer declarer) {
+ declarer.declare(new Fields("id", "event"));
+ }
+}
View
208 storm-scribe/src/jvm/storm/scribe/ScribeReceiver.java
@@ -0,0 +1,208 @@
+package storm.scribe;
+
+import backtype.storm.task.TopologyContext;
+import backtype.storm.utils.Utils;
+import com.netflix.curator.framework.CuratorFramework;
+import com.netflix.curator.framework.CuratorFrameworkFactory;
+import com.netflix.curator.retry.RetryNTimes;
+import storm.scribe.generated.LogEntry;
+import storm.scribe.generated.ResultCode;
+import storm.scribe.generated.fb_status;
+import storm.scribe.generated.scribe;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.thrift7.protocol.TBinaryProtocol;
+import org.apache.thrift7.server.TServer;
+import org.apache.thrift7.TException;
+import org.apache.thrift7.server.THsHaServer;
+import org.apache.thrift7.transport.TNonblockingServerSocket;
+import org.apache.thrift7.transport.TTransportException;
+import org.apache.zookeeper.CreateMode;
+
+public class ScribeReceiver {
+ LinkedBlockingQueue<byte[]> _events;
+ volatile boolean _active = false;
+ volatile boolean _scribeActive = false;
+ final Object _scribeLock = new Object();
+ TServer _server;
+ String _zkStr;
+ String _zkRoot;
+ CuratorFramework _zk;
+
+ public static LinkedBlockingQueue<byte[]> makeEventsQueue(Map conf) {
+ Number bufferSize = (Number) conf.get("scribe.spout.buffer.size");
+ if(bufferSize==null) bufferSize = 10000;
+ return new LinkedBlockingQueue<byte[]>(bufferSize.intValue());
+ }
+
+ public ScribeReceiver(LinkedBlockingQueue<byte[]> events, Map conf, TopologyContext context, String zkStr, String zkRoot) {
+ _zkStr = zkStr;
+ _zkRoot = zkRoot;
+ _events = events;
+
+ Number putTimeout = (Number) conf.get("scribe.spout.put.timeout");
+ if(putTimeout==null) putTimeout = 5;
+
+ Number portDelta = (Number) conf.get("scribe.spout.port.delta");
+ if(portDelta==null) putTimeout = 2000;
+
+ int port = context.getThisWorkerPort() + portDelta.intValue();
+
+ String host;
+ try {
+ host = InetAddress.getLocalHost().getCanonicalHostName();
+ } catch (UnknownHostException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ try {
+ _zk = CuratorFrameworkFactory.newClient(
+ _zkStr,
+ 30000,
+ 15000,
+ new RetryNTimes(4, 1000));
+ _zk.create()
+ .creatingParentsIfNeeded()
+ .withMode(CreateMode.EPHEMERAL)
+ .forPath(_zkRoot + "/" + host + ":" + port);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+
+ ScribeServiceHandler handler = new ScribeServiceHandler(putTimeout.intValue());
+ try {
+ //TODO: more efficient as just a nonblockingserver?
+ THsHaServer.Args args = new THsHaServer.Args(new TNonblockingServerSocket(port))
+ .workerThreads(1)
+ .protocolFactory(new TBinaryProtocol.Factory())
+ .processor(new scribe.Processor(handler));
+
+ _server = new THsHaServer(args);
+ _server.serve();
+ } catch (TTransportException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public void shutdown() {
+ _server.stop();
+ _zk.close();
+ }
+
+ public void activate() {
+ _active = true;
+ }
+
+ public void deactivate() {
+ _active = false;
+ while(true) {
+ synchronized(_scribeLock) {
+ if(_scribeActive) {
+ Utils.sleep(10);
+ } else {
+ break;
+ }
+ }
+ }
+ }
+
+ private class ScribeServiceHandler implements scribe.Iface {
+ long _startTime;
+ int _putTimeoutSecs;
+
+ public ScribeServiceHandler(int putTimeoutSecs) {
+ _startTime = System.currentTimeMillis();
+ _putTimeoutSecs = putTimeoutSecs;
+ }
+
+ @Override
+ public ResultCode Log(List<LogEntry> messages) throws TException {
+ synchronized(_scribeLock) {
+ if(!_active) return ResultCode.TRY_LATER;
+ _scribeActive = true;
+ }
+ for(LogEntry le: messages) {
+ try {
+ byte[] o = Base64.decodeBase64(le.get_message());
+ boolean taken = _events.offer(o, _putTimeoutSecs, TimeUnit.SECONDS);
+ if(!taken) return ResultCode.TRY_LATER;
+ } catch(InterruptedException ex) {
+ throw new TException(ex);
+ }
+ }
+ //TODO: for a reliable spout, need to *block* (with timeout) here until every single tuple gets acked
+ _scribeActive = false;
+ return ResultCode.OK;
+ }
+
+ @Override
+ public void shutdown() throws TException {
+
+ }
+
+ @Override
+ public String getName() throws TException {
+ return "rainbird-scribe-spout";
+ }
+
+ @Override
+ public String getVersion() throws TException {
+ return "0.0.1";
+ }
+
+ @Override
+ public fb_status getStatus() throws TException {
+ return fb_status.ALIVE;
+ }
+
+ @Override
+ public String getStatusDetails() throws TException {
+ return "n/a";
+ }
+
+ @Override
+ public Map<String, Long> getCounters() throws TException {
+ return new HashMap<String, Long>();
+ }
+
+ @Override
+ public long getCounter(String key) throws TException {
+ return 0L;
+ }
+
+ @Override
+ public void setOption(String key, String value) throws TException {
+ }
+
+ @Override
+ public String getOption(String key) throws TException {
+ return "";
+ }
+
+ @Override
+ public Map<String, String> getOptions() throws TException {
+ return new HashMap<String, String>();
+ }
+
+ @Override
+ public String getCpuProfile(int profileDurationInSec) throws TException {
+ return "n/a";
+ }
+
+ @Override
+ public long aliveSince() throws TException {
+ return _startTime;
+ }
+
+ @Override
+ public void reinitialize() throws TException {
+ }
+
+ }
+}
View
71 storm-scribe/src/jvm/storm/scribe/ScribeSpout.java
@@ -0,0 +1,71 @@
+package storm.scribe;
+
+import backtype.storm.spout.RawScheme;
+import backtype.storm.spout.Scheme;
+import backtype.storm.spout.SpoutOutputCollector;
+import backtype.storm.task.TopologyContext;
+import backtype.storm.topology.OutputFieldsDeclarer;
+import backtype.storm.topology.base.BaseRichSpout;
+import backtype.storm.tuple.Values;
+import java.util.Map;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class ScribeSpout extends BaseRichSpout {
+ SpoutOutputCollector _collector;
+ LinkedBlockingQueue<byte[]> _events;
+ Scheme _scheme;
+ ScribeReceiver _receiver;
+ String _zkStr;
+ String _zkRoot;
+
+ public ScribeSpout(String zkStr, String zkRoot, Scheme scheme) {
+ _zkStr = zkStr;
+ _zkRoot = zkRoot;
+ _scheme = scheme;
+ }
+
+ public ScribeSpout(String zkStr, String zkRoot) {
+ this(zkStr, zkRoot, new RawScheme());
+ }
+
+ @Override
+ public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
+ _collector = collector;
+ _events = ScribeReceiver.makeEventsQueue(conf);
+ _receiver = new ScribeReceiver(_events, conf, context, _zkStr, _zkRoot);
+ }
+
+ @Override
+ public void nextTuple() {
+ byte[] o = _events.poll();
+ if(o!=null) {
+ _collector.emit(new Values(_scheme.deserialize(o)));
+ }
+ }
+
+ @Override
+ public void activate() {
+ _receiver.activate();
+ }
+
+ @Override
+ public void deactivate() {
+ _receiver.deactivate();
+
+ // flush buffer on deactivation
+ // this might not respect topology-max-spout-pending, but it's the best we can do
+ while(!_events.isEmpty()) {
+ nextTuple();
+ }
+ }
+
+ @Override
+ public void close() {
+ _receiver.shutdown();
+ }
+
+ @Override
+ public void declareOutputFields(OutputFieldsDeclarer declarer) {
+ declarer.declare(_scheme.getOutputFields());
+ }
+}
View
7,490 storm-scribe/src/jvm/storm/scribe/generated/FacebookService.java
7,490 additions, 0 deletions not shown
View
417 storm-scribe/src/jvm/storm/scribe/generated/LogEntry.java
@@ -0,0 +1,417 @@
+/**
+ * Autogenerated by Thrift Compiler (0.7.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package storm.scribe.generated;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LogEntry implements org.apache.thrift7.TBase<LogEntry, LogEntry._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift7.protocol.TStruct STRUCT_DESC = new org.apache.thrift7.protocol.TStruct("LogEntry");
+
+ private static final org.apache.thrift7.protocol.TField CATEGORY_FIELD_DESC = new org.apache.thrift7.protocol.TField("category", org.apache.thrift7.protocol.TType.STRING, (short)1);
+ private static final org.apache.thrift7.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift7.protocol.TField("message", org.apache.thrift7.protocol.TType.STRING, (short)2);
+
+ private String category; // required
+ private String message; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift7.TFieldIdEnum {
+ CATEGORY((short)1, "category"),
+ MESSAGE((short)2, "message");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // CATEGORY
+ return CATEGORY;
+ case 2: // MESSAGE
+ return MESSAGE;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, org.apache.thrift7.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift7.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift7.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.CATEGORY, new org.apache.thrift7.meta_data.FieldMetaData("category", org.apache.thrift7.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift7.meta_data.FieldValueMetaData(org.apache.thrift7.protocol.TType.STRING)));
+ tmpMap.put(_Fields.MESSAGE, new org.apache.thrift7.meta_data.FieldMetaData("message", org.apache.thrift7.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift7.meta_data.FieldValueMetaData(org.apache.thrift7.protocol.TType.STRING)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift7.meta_data.FieldMetaData.addStructMetaDataMap(LogEntry.class, metaDataMap);
+ }
+
+ public LogEntry() {
+ }
+
+ public LogEntry(
+ String category,
+ String message)
+ {
+ this();
+ this.category = category;
+ this.message = message;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public LogEntry(LogEntry other) {
+ if (other.is_set_category()) {
+ this.category = other.category;
+ }
+ if (other.is_set_message()) {
+ this.message = other.message;
+ }
+ }
+
+ public LogEntry deepCopy() {
+ return new LogEntry(this);
+ }
+
+ @Override
+ public void clear() {
+ this.category = null;
+ this.message = null;
+ }
+
+ public String get_category() {
+ return this.category;
+ }
+
+ public void set_category(String category) {
+ this.category = category;
+ }
+
+ public void unset_category() {
+ this.category = null;
+ }
+
+ /** Returns true if field category is set (has been assigned a value) and false otherwise */
+ public boolean is_set_category() {
+ return this.category != null;
+ }
+
+ public void set_category_isSet(boolean value) {
+ if (!value) {
+ this.category = null;
+ }
+ }
+
+ public String get_message() {
+ return this.message;
+ }
+
+ public void set_message(String message) {
+ this.message = message;
+ }
+
+ public void unset_message() {
+ this.message = null;
+ }
+
+ /** Returns true if field message is set (has been assigned a value) and false otherwise */
+ public boolean is_set_message() {
+ return this.message != null;
+ }
+
+ public void set_message_isSet(boolean value) {
+ if (!value) {
+ this.message = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case CATEGORY:
+ if (value == null) {
+ unset_category();
+ } else {
+ set_category((String)value);
+ }
+ break;
+
+ case MESSAGE:
+ if (value == null) {
+ unset_message();
+ } else {
+ set_message((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case CATEGORY:
+ return get_category();
+
+ case MESSAGE:
+ return get_message();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case CATEGORY:
+ return is_set_category();
+ case MESSAGE:
+ return is_set_message();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof LogEntry)
+ return this.equals((LogEntry)that);
+ return false;
+ }
+
+ public boolean equals(LogEntry that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_category = true && this.is_set_category();
+ boolean that_present_category = true && that.is_set_category();
+ if (this_present_category || that_present_category) {
+ if (!(this_present_category && that_present_category))
+ return false;
+ if (!this.category.equals(that.category))
+ return false;
+ }
+
+ boolean this_present_message = true && this.is_set_message();
+ boolean that_present_message = true && that.is_set_message();
+ if (this_present_message || that_present_message) {
+ if (!(this_present_message && that_present_message))
+ return false;
+ if (!this.message.equals(that.message))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_category = true && (is_set_category());
+ builder.append(present_category);
+ if (present_category)
+ builder.append(category);
+
+ boolean present_message = true && (is_set_message());
+ builder.append(present_message);
+ if (present_message)
+ builder.append(message);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(LogEntry other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ LogEntry typedOther = (LogEntry)other;
+
+ lastComparison = Boolean.valueOf(is_set_category()).compareTo(typedOther.is_set_category());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (is_set_category()) {
+ lastComparison = org.apache.thrift7.TBaseHelper.compareTo(this.category, typedOther.category);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(is_set_message()).compareTo(typedOther.is_set_message());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (is_set_message()) {
+ lastComparison = org.apache.thrift7.TBaseHelper.compareTo(this.message, typedOther.message);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift7.protocol.TProtocol iprot) throws org.apache.thrift7.TException {
+ org.apache.thrift7.protocol.TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == org.apache.thrift7.protocol.TType.STOP) {
+ break;
+ }
+ switch (field.id) {
+ case 1: // CATEGORY
+ if (field.type == org.apache.thrift7.protocol.TType.STRING) {
+ this.category = iprot.readString();
+ } else {
+ org.apache.thrift7.protocol.TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ case 2: // MESSAGE
+ if (field.type == org.apache.thrift7.protocol.TType.STRING) {
+ this.message = iprot.readString();
+ } else {
+ org.apache.thrift7.protocol.TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ default:
+ org.apache.thrift7.protocol.TProtocolUtil.skip(iprot, field.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ validate();
+ }
+
+ public void write(org.apache.thrift7.protocol.TProtocol oprot) throws org.apache.thrift7.TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (this.category != null) {
+ oprot.writeFieldBegin(CATEGORY_FIELD_DESC);
+ oprot.writeString(this.category);
+ oprot.writeFieldEnd();
+ }
+ if (this.message != null) {
+ oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+ oprot.writeString(this.message);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("LogEntry(");
+ boolean first = true;
+
+ sb.append("category:");
+ if (this.category == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.category);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("message:");
+ if (this.message == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.message);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift7.TException {
+ // check for required fields
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift7.protocol.TCompactProtocol(new org.apache.thrift7.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift7.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift7.protocol.TCompactProtocol(new org.apache.thrift7.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift7.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+}
+
View
44 storm-scribe/src/jvm/storm/scribe/generated/ResultCode.java
@@ -0,0 +1,44 @@
+/**
+ * Autogenerated by Thrift Compiler (0.7.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package storm.scribe.generated;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift7.TEnum;
+
+public enum ResultCode implements org.apache.thrift7.TEnum {
+ OK(0),
+ TRY_LATER(1);
+
+ private final int value;
+
+ private ResultCode(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Get the integer value of this enum value, as defined in the Thrift IDL.
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Find a the enum type by its integer value, as defined in the Thrift IDL.
+ * @return null if the value is not found.
+ */
+ public static ResultCode findByValue(int value) {
+ switch (value) {
+ case 0:
+ return OK;
+ case 1:
+ return TRY_LATER;
+ default:
+ return null;
+ }
+ }
+}
View
59 storm-scribe/src/jvm/storm/scribe/generated/fb_status.java
@@ -0,0 +1,59 @@
+/**
+ * Autogenerated by Thrift Compiler (0.7.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package storm.scribe.generated;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import org.apache.thrift7.TEnum;
+
+/**
+ * Common status reporting mechanism across all services
+ */
+public enum fb_status implements org.apache.thrift7.TEnum {
+ DEAD(0),
+ STARTING(1),
+ ALIVE(2),
+ STOPPING(3),
+ STOPPED(4),
+ WARNING(5);
+
+ private final int value;
+
+ private fb_status(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Get the integer value of this enum value, as defined in the Thrift IDL.
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Find a the enum type by its integer value, as defined in the Thrift IDL.
+ * @return null if the value is not found.
+ */
+ public static fb_status findByValue(int value) {
+ switch (value) {
+ case 0:
+ return DEAD;
+ case 1:
+ return STARTING;
+ case 2:
+ return ALIVE;
+ case 3:
+ return STOPPING;
+ case 4:
+ return STOPPED;
+ case 5:
+ return WARNING;
+ default:
+ return null;
+ }
+ }
+}
View
817 storm-scribe/src/jvm/storm/scribe/generated/scribe.java
@@ -0,0 +1,817 @@
+/**
+ * Autogenerated by Thrift Compiler (0.7.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+package storm.scribe.generated;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class scribe {
+
+ public interface Iface extends storm.scribe.generated.FacebookService.Iface {
+
+ public ResultCode Log(List<LogEntry> messages) throws org.apache.thrift7.TException;
+
+ }
+
+ public interface AsyncIface extends storm.scribe.generated.FacebookService .AsyncIface {
+
+ public void Log(List<LogEntry> messages, org.apache.thrift7.async.AsyncMethodCallback<AsyncClient.Log_call> resultHandler) throws org.apache.thrift7.TException;
+
+ }
+
+ public static class Client extends storm.scribe.generated.FacebookService.Client implements Iface {
+ public static class Factory implements org.apache.thrift7.TServiceClientFactory<Client> {
+ public Factory() {}
+ public Client getClient(org.apache.thrift7.protocol.TProtocol prot) {
+ return new Client(prot);
+ }
+ public Client getClient(org.apache.thrift7.protocol.TProtocol iprot, org.apache.thrift7.protocol.TProtocol oprot) {
+ return new Client(iprot, oprot);
+ }
+ }
+
+ public Client(org.apache.thrift7.protocol.TProtocol prot)
+ {
+ super(prot, prot);
+ }
+
+ public Client(org.apache.thrift7.protocol.TProtocol iprot, org.apache.thrift7.protocol.TProtocol oprot) {
+ super(iprot, oprot);
+ }
+
+ public ResultCode Log(List<LogEntry> messages) throws org.apache.thrift7.TException
+ {
+ send_Log(messages);
+ return recv_Log();
+ }
+
+ public void send_Log(List<LogEntry> messages) throws org.apache.thrift7.TException
+ {
+ Log_args args = new Log_args();
+ args.set_messages(messages);
+ sendBase("Log", args);
+ }
+
+ public ResultCode recv_Log() throws org.apache.thrift7.TException
+ {
+ Log_result result = new Log_result();
+ receiveBase(result, "Log");
+ if (result.is_set_success()) {
+ return result.success;
+ }
+ throw new org.apache.thrift7.TApplicationException(org.apache.thrift7.TApplicationException.MISSING_RESULT, "Log failed: unknown result");
+ }
+
+ }
+ public static class AsyncClient extends storm.scribe.generated.FacebookService.AsyncClient implements AsyncIface {
+ public static class Factory implements org.apache.thrift7.async.TAsyncClientFactory<AsyncClient> {
+ private org.apache.thrift7.async.TAsyncClientManager clientManager;
+ private org.apache.thrift7.protocol.TProtocolFactory protocolFactory;
+ public Factory(org.apache.thrift7.async.TAsyncClientManager clientManager, org.apache.thrift7.protocol.TProtocolFactory protocolFactory) {
+ this.clientManager = clientManager;
+ this.protocolFactory = protocolFactory;
+ }
+ public AsyncClient getAsyncClient(org.apache.thrift7.transport.TNonblockingTransport transport) {
+ return new AsyncClient(protocolFactory, clientManager, transport);
+ }
+ }
+
+ public AsyncClient(org.apache.thrift7.protocol.TProtocolFactory protocolFactory, org.apache.thrift7.async.TAsyncClientManager clientManager, org.apache.thrift7.transport.TNonblockingTransport transport) {
+ super(protocolFactory, clientManager, transport);
+ }
+
+ public void Log(List<LogEntry> messages, org.apache.thrift7.async.AsyncMethodCallback<Log_call> resultHandler) throws org.apache.thrift7.TException {
+ checkReady();
+ Log_call method_call = new Log_call(messages, resultHandler, this, ___protocolFactory, ___transport);
+ this.___currentMethod = method_call;
+ ___manager.call(method_call);
+ }
+
+ public static class Log_call extends org.apache.thrift7.async.TAsyncMethodCall {
+ private List<LogEntry> messages;
+ public Log_call(List<LogEntry> messages, org.apache.thrift7.async.AsyncMethodCallback<Log_call> resultHandler, org.apache.thrift7.async.TAsyncClient client, org.apache.thrift7.protocol.TProtocolFactory protocolFactory, org.apache.thrift7.transport.TNonblockingTransport transport) throws org.apache.thrift7.TException {
+ super(client, protocolFactory, transport, resultHandler, false);
+ this.messages = messages;
+ }
+
+ public void write_args(org.apache.thrift7.protocol.TProtocol prot) throws org.apache.thrift7.TException {
+ prot.writeMessageBegin(new org.apache.thrift7.protocol.TMessage("Log", org.apache.thrift7.protocol.TMessageType.CALL, 0));
+ Log_args args = new Log_args();
+ args.set_messages(messages);
+ args.write(prot);
+ prot.writeMessageEnd();
+ }
+
+ public ResultCode getResult() throws org.apache.thrift7.TException {
+ if (getState() != org.apache.thrift7.async.TAsyncMethodCall.State.RESPONSE_READ) {
+ throw new IllegalStateException("Method call not finished!");
+ }
+ org.apache.thrift7.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift7.transport.TMemoryInputTransport(getFrameBuffer().array());
+ org.apache.thrift7.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
+ return (new Client(prot)).recv_Log();
+ }
+ }
+
+ }
+
+ public static class Processor<I extends Iface> extends storm.scribe.generated.FacebookService.Processor implements org.apache.thrift7.TProcessor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
+ public Processor(I iface) {
+ super(iface, getProcessMap(new HashMap<String, org.apache.thrift7.ProcessFunction<I, ? extends org.apache.thrift7.TBase>>()));
+ }
+
+ protected Processor(I iface, Map<String, org.apache.thrift7.ProcessFunction<I, ? extends org.apache.thrift7.TBase>> processMap) {
+ super(iface, getProcessMap(processMap));
+ }
+
+ private static <I extends Iface> Map<String, org.apache.thrift7.ProcessFunction<I, ? extends org.apache.thrift7.TBase>> getProcessMap(Map<String, org.apache.thrift7.ProcessFunction<I, ? extends org.apache.thrift7.TBase>> processMap) {
+ processMap.put("Log", new Log());
+ return processMap;
+ }
+
+ private static class Log<I extends Iface> extends org.apache.thrift7.ProcessFunction<I, Log_args> {
+ public Log() {
+ super("Log");
+ }
+
+ protected Log_args getEmptyArgsInstance() {
+ return new Log_args();
+ }
+
+ protected Log_result getResult(I iface, Log_args args) throws org.apache.thrift7.TException {
+ Log_result result = new Log_result();
+ result.success = iface.Log(args.messages);
+ return result;
+ }
+ }
+
+ }
+
+ public static class Log_args implements org.apache.thrift7.TBase<Log_args, Log_args._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift7.protocol.TStruct STRUCT_DESC = new org.apache.thrift7.protocol.TStruct("Log_args");
+
+ private static final org.apache.thrift7.protocol.TField MESSAGES_FIELD_DESC = new org.apache.thrift7.protocol.TField("messages", org.apache.thrift7.protocol.TType.LIST, (short)1);
+
+ private List<LogEntry> messages; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift7.TFieldIdEnum {
+ MESSAGES((short)1, "messages");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // MESSAGES
+ return MESSAGES;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, org.apache.thrift7.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift7.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift7.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.MESSAGES, new org.apache.thrift7.meta_data.FieldMetaData("messages", org.apache.thrift7.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift7.meta_data.ListMetaData(org.apache.thrift7.protocol.TType.LIST,
+ new org.apache.thrift7.meta_data.StructMetaData(org.apache.thrift7.protocol.TType.STRUCT, LogEntry.class))));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift7.meta_data.FieldMetaData.addStructMetaDataMap(Log_args.class, metaDataMap);
+ }
+
+ public Log_args() {
+ }
+
+ public Log_args(
+ List<LogEntry> messages)
+ {
+ this();
+ this.messages = messages;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public Log_args(Log_args other) {
+ if (other.is_set_messages()) {
+ List<LogEntry> __this__messages = new ArrayList<LogEntry>();
+ for (LogEntry other_element : other.messages) {
+ __this__messages.add(new LogEntry(other_element));
+ }
+ this.messages = __this__messages;
+ }
+ }
+
+ public Log_args deepCopy() {
+ return new Log_args(this);
+ }
+
+ @Override
+ public void clear() {
+ this.messages = null;
+ }
+
+ public int get_messages_size() {
+ return (this.messages == null) ? 0 : this.messages.size();
+ }
+
+ public java.util.Iterator<LogEntry> get_messages_iterator() {
+ return (this.messages == null) ? null : this.messages.iterator();
+ }
+
+ public void add_to_messages(LogEntry elem) {
+ if (this.messages == null) {
+ this.messages = new ArrayList<LogEntry>();
+ }
+ this.messages.add(elem);
+ }
+
+ public List<LogEntry> get_messages() {
+ return this.messages;
+ }
+
+ public void set_messages(List<LogEntry> messages) {
+ this.messages = messages;
+ }
+
+ public void unset_messages() {
+ this.messages = null;
+ }
+
+ /** Returns true if field messages is set (has been assigned a value) and false otherwise */
+ public boolean is_set_messages() {
+ return this.messages != null;
+ }
+
+ public void set_messages_isSet(boolean value) {
+ if (!value) {
+ this.messages = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case MESSAGES:
+ if (value == null) {
+ unset_messages();
+ } else {
+ set_messages((List<LogEntry>)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case MESSAGES:
+ return get_messages();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case MESSAGES:
+ return is_set_messages();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof Log_args)
+ return this.equals((Log_args)that);
+ return false;
+ }
+
+ public boolean equals(Log_args that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_messages = true && this.is_set_messages();
+ boolean that_present_messages = true && that.is_set_messages();
+ if (this_present_messages || that_present_messages) {
+ if (!(this_present_messages && that_present_messages))
+ return false;
+ if (!this.messages.equals(that.messages))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_messages = true && (is_set_messages());
+ builder.append(present_messages);
+ if (present_messages)
+ builder.append(messages);
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(Log_args other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ Log_args typedOther = (Log_args)other;
+
+ lastComparison = Boolean.valueOf(is_set_messages()).compareTo(typedOther.is_set_messages());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (is_set_messages()) {
+ lastComparison = org.apache.thrift7.TBaseHelper.compareTo(this.messages, typedOther.messages);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift7.protocol.TProtocol iprot) throws org.apache.thrift7.TException {
+ org.apache.thrift7.protocol.TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == org.apache.thrift7.protocol.TType.STOP) {
+ break;
+ }
+ switch (field.id) {
+ case 1: // MESSAGES
+ if (field.type == org.apache.thrift7.protocol.TType.LIST) {
+ {
+ org.apache.thrift7.protocol.TList _list0 = iprot.readListBegin();
+ this.messages = new ArrayList<LogEntry>(_list0.size);
+ for (int _i1 = 0; _i1 < _list0.size; ++_i1)
+ {
+ LogEntry _elem2; // required
+ _elem2 = new LogEntry();
+ _elem2.read(iprot);
+ this.messages.add(_elem2);
+ }
+ iprot.readListEnd();
+ }
+ } else {
+ org.apache.thrift7.protocol.TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ default:
+ org.apache.thrift7.protocol.TProtocolUtil.skip(iprot, field.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ validate();
+ }
+
+ public void write(org.apache.thrift7.protocol.TProtocol oprot) throws org.apache.thrift7.TException {
+ validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (this.messages != null) {
+ oprot.writeFieldBegin(MESSAGES_FIELD_DESC);
+ {
+ oprot.writeListBegin(new org.apache.thrift7.protocol.TList(org.apache.thrift7.protocol.TType.STRUCT, this.messages.size()));
+ for (LogEntry _iter3 : this.messages)
+ {
+ _iter3.write(oprot);
+ }
+ oprot.writeListEnd();
+ }
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("Log_args(");
+ boolean first = true;
+
+ sb.append("messages:");
+ if (this.messages == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.messages);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift7.TException {
+ // check for required fields
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift7.protocol.TCompactProtocol(new org.apache.thrift7.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift7.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift7.protocol.TCompactProtocol(new org.apache.thrift7.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift7.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ }
+
+ public static class Log_result implements org.apache.thrift7.TBase<Log_result, Log_result._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift7.protocol.TStruct STRUCT_DESC = new org.apache.thrift7.protocol.TStruct("Log_result");
+
+ private static final org.apache.thrift7.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift7.protocol.TField("success", org.apache.thrift7.protocol.TType.I32, (short)0);
+
+ private ResultCode success; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift7.TFieldIdEnum {
+ /**
+ *
+ * @see ResultCode
+ */
+ SUCCESS((short)0, "success");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 0: // SUCCESS
+ return SUCCESS;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+
+ public static final Map<_Fields, org.apache.thrift7.meta_data.FieldMetaData> metaDataMap;
+ static {
+ Map<_Fields, org.apache.thrift7.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift7.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.SUCCESS, new org.apache.thrift7.meta_data.FieldMetaData("success", org.apache.thrift7.TFieldRequirementType.DEFAULT,
+ new org.apache.thrift7.meta_data.EnumMetaData(org.apache.thrift7.protocol.TType.ENUM, ResultCode.class)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift7.meta_data.FieldMetaData.addStructMetaDataMap(Log_result.class, metaDataMap);
+ }
+
+ public Log_result() {
+ }
+
+ public Log_result(
+ ResultCode success)
+ {
+ this();
+ this.success = success;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public Log_result(Log_result other) {
+ if (other.is_set_success()) {
+ this.success = other.success;
+ }
+ }
+
+ public Log_result deepCopy() {
+ return new Log_result(this);
+ }
+
+ @Override
+ public void clear() {
+ this.success = null;
+ }
+
+ /**
+ *
+ * @see ResultCode
+ */
+ public ResultCode get_success() {
+ return this.success;
+ }
+
+ /**
+ *
+ * @see ResultCode
+ */
+ public void set_success(ResultCode success) {
+ this.success = success;
+ }
+
+ public void unset_success() {
+ this.success = null;
+ }
+
+ /** Returns true if field success is set (has been assigned a value) and false otherwise */
+ public boolean is_set_success() {
+ return this.success != null;
+ }
+
+ public void set_success_isSet(boolean value) {
+ if (!value) {
+ this.success = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case SUCCESS:
+ if (value == null) {
+ unset_success();
+ } else {
+ set_success((ResultCode)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case SUCCESS:
+ return get_success();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case SUCCESS:
+ return is_set_success();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof Log_result)
+ return this.equals((Log_result)that);
+ return false;
+ }
+
+ public boolean equals(Log_result that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_success = true && this.is_set_success();
+ boolean that_present_success = true && that.is_set_success();
+ if (this_present_success || that_present_success) {
+ if (!(this_present_success && that_present_success))
+ return false;
+ if (!this.success.equals(that.success))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ HashCodeBuilder builder = new HashCodeBuilder();
+
+ boolean present_success = true && (is_set_success());
+ builder.append(present_success);
+ if (present_success)
+ builder.append(success.getValue());
+
+ return builder.toHashCode();
+ }
+
+ public int compareTo(Log_result other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ Log_result typedOther = (Log_result)other;
+
+ lastComparison = Boolean.valueOf(is_set_success()).compareTo(typedOther.is_set_success());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (is_set_success()) {
+ lastComparison = org.apache.thrift7.TBaseHelper.compareTo(this.success, typedOther.success);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift7.protocol.TProtocol iprot) throws org.apache.thrift7.TException {
+ org.apache.thrift7.protocol.TField field;
+ iprot.readStructBegin();
+ while (true)
+ {
+ field = iprot.readFieldBegin();
+ if (field.type == org.apache.thrift7.protocol.TType.STOP) {
+ break;
+ }
+ switch (field.id) {
+ case 0: // SUCCESS
+ if (field.type == org.apache.thrift7.protocol.TType.I32) {
+ this.success = ResultCode.findByValue(iprot.readI32());
+ } else {
+ org.apache.thrift7.protocol.TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ default:
+ org.apache.thrift7.protocol.TProtocolUtil.skip(iprot, field.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+ validate();
+ }
+
+ public void write(org.apache.thrift7.protocol.TProtocol oprot) throws org.apache.thrift7.TException {
+ oprot.writeStructBegin(STRUCT_DESC);
+
+ if (this.is_set_success()) {
+ oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+ oprot.writeI32(this.success.getValue());
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("Log_result(");
+ boolean first = true;
+
+ sb.append("success:");
+ if (this.success == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.success);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift7.TException {
+ // check for required fields
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift7.protocol.TCompactProtocol(new org.apache.thrift7.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift7.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ read(new org.apache.thrift7.protocol.TCompactProtocol(new org.apache.thrift7.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift7.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ }
+
+}
View
39 storm-scribe/src/scribe.thrift
@@ -0,0 +1,39 @@
+#!/usr/local/bin/thrift --cpp --php
+
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## 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.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+include "fb303/if/fb303.thrift"
+
+namespace java storm.scribe.generated
+
+enum ResultCode
+{
+ OK,
+ TRY_LATER
+}
+
+struct LogEntry
+{
+ 1: string category,
+ 2: string message
+}
+
+service scribe extends fb303.FacebookService
+{
+ ResultCode Log(1: list<LogEntry> messages);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.