cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r904973 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/streaming/PendingFile.java
Date Sun, 31 Jan 2010 04:02:08 GMT
Author: jbellis
Date: Sun Jan 31 04:02:07 2010
New Revision: 904973

URL: http://svn.apache.org/viewvc?rev=904973&view=rev
Log:
add missing PendingFile.java

Added:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/streaming/PendingFile.java   (with
props)

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/streaming/PendingFile.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/streaming/PendingFile.java?rev=904973&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/streaming/PendingFile.java (added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/streaming/PendingFile.java Sun
Jan 31 04:02:07 2010
@@ -0,0 +1,90 @@
+package org.apache.cassandra.streaming;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.cassandra.io.ICompactSerializer;
+
+class PendingFile
+{
+    private static ICompactSerializer<PendingFile> serializer_;
+
+    static
+    {
+        serializer_ = new InitiatedFileSerializer();
+    }
+
+    public static ICompactSerializer<PendingFile> serializer()
+    {
+        return serializer_;
+    }
+
+    private String targetFile_;
+    private long expectedBytes_;
+    private String table_;
+
+    public PendingFile(String targetFile, long expectedBytes, String table)
+    {
+        targetFile_ = targetFile;
+        expectedBytes_ = expectedBytes;
+        table_ = table;
+    }
+
+    public String getTable()
+    {
+        return table_;
+    }
+
+    public String getTargetFile()
+    {
+        return targetFile_;
+    }
+
+    public void setTargetFile(String file)
+    {
+        targetFile_ = file;
+    }
+
+    public long getExpectedBytes()
+    {
+        return expectedBytes_;
+    }
+
+    public boolean equals(Object o)
+    {
+        if ( !(o instanceof PendingFile) )
+            return false;
+
+        PendingFile rhs = (PendingFile)o;
+        return targetFile_.equals(rhs.targetFile_);
+    }
+
+    public int hashCode()
+    {
+        return toString().hashCode();
+    }
+
+    public String toString()
+    {
+        return targetFile_ + ":" + expectedBytes_;
+    }
+
+    private static class InitiatedFileSerializer implements ICompactSerializer<PendingFile>
+    {
+        public void serialize(PendingFile sc, DataOutputStream dos) throws IOException
+        {
+            dos.writeUTF(sc.targetFile_);
+            dos.writeLong(sc.expectedBytes_);
+            dos.writeUTF(sc.table_);
+        }
+
+        public PendingFile deserialize(DataInputStream dis) throws IOException
+        {
+            String targetFile = dis.readUTF();
+            long expectedBytes = dis.readLong();
+            String table = dis.readUTF();
+            return new PendingFile(targetFile, expectedBytes, table);
+        }
+    }
+}

Propchange: incubator/cassandra/trunk/src/java/org/apache/cassandra/streaming/PendingFile.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message