416DAT

Check-in [cdfb64a865]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cleaned up a bit more stuff
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:cdfb64a8651cd6c5ae82831b3128632c450a32eb
User & Date: jchezenko 2013-04-09 06:37:16
Context
2013-04-09
06:41
updated readme! check-in: 08b4a862db user: jchezenko tags: trunk
06:37
cleaned up a bit more stuff check-in: cdfb64a865 user: jchezenko tags: trunk
06:33
cleand up duplicate couchbase clients and boring files check-in: af1efca2d4 user: jchezenko tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Deleted Jesse/CouchClient.java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;

import com.couchbase.client.CouchbaseClient;
import java.io.IOException;
import java.net.URI;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import net.spy.memcached.internal.OperationFuture;

import com.yahoo.ycsb.ByteArrayByteIterator;
import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.DB;
import com.yahoo.ycsb.DBException;

public class CouchClient extends DB {


  // the unique key of the document
  public static final String KEY = "beer_Wrath";

  // expiration time of the document (use 0 to persist forever)
  public static final int EXP_TIME = 0;
  public CouchbaseClient client = null;

  public CouchClient(){
    client=null;
  }

  public void init() throws DBException {

    Properties props = getProperties();
    //do soemethign with properties.
    props.list(System.out);

    // Set the URIs and get a client
    List<URI> uris = new LinkedList<URI>();

    // Connect to localhost or to the appropriate URI(s)
    //uris.add(URI.create("http://192.168.1.101:8091/pools"));
    uris.add(URI.create("http://localhost:8091/pools"));

    try {
      // Use the "default" bucket with no password
      client = new CouchbaseClient(uris, "usertable", "");
      System.out.println("couch base connected!");
    } catch (IOException e) {
      System.err.println("IOException connecting to Couchbase: " + e.getMessage());
      System.exit(1);
    }    

  }

   //Read a single record
  @Override
  public int read(String table, String key, Set<String> fields, HashMap<String,ByteIterator> result){
      //System.out.println("Couchbase client: inside read");
    Object obj;
    obj = client.get(key);
    return 0;
  }

  //Perform a range scan
  @Override
  public int scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String,ByteIterator>> result){
      //System.out.println("Couchbase client: inside scan");
   return 0;
  }
  
  //Update a single record
  @Override
  public int update(String table, String key, HashMap<String,ByteIterator> values){
      //System.out.println("Couchbase client: inside update");
    client.replace(key,0,"blahblah");
    return 0;
  }

  //Insert a single record
  @Override
  public int insert(String table, String key, HashMap<String,ByteIterator> values){
      // Do an asynchronous set
    //System.out.println("the table is: " + table);
    //System.out.println("the key is :" + key);

    //System.out.println("the values are as follows");
    //System.out.println("the size of the hash map is:" + values.size());
      
    
    OperationFuture<Boolean> setOp = client.set(key, 0,"testValue");
    //System.out.println("set the testvalue");

    // long unixTime = System.currentTimeMillis() / 1000L;
    // if(unixTime % 60==0){
    // 	//System.out.println(unixTime);
    // }
    
    // Check to see if our set succeeded
    try {
      if (setOp.get().booleanValue()) {
        //System.out.println("Set Succeeded");
      } else {
        System.err.println("Set failed: " + setOp.getStatus().getMessage());
        return 1;
      }
    } catch (InterruptedException e) {
      System.err.println("InterruptedException while doing set: " + e.getMessage());
      return 1;
    } catch (ExecutionException e) {
      System.err.println("ExecutionException while doing set: " + e.getMessage());
      return 1;
    }

    // Shutdown and wait a maximum of three seconds to finish up operations
    //client.shutdown(3, TimeUnit.SECONDS);
    //System.out.println("Couchbase client: inside insert");
    return 0;
  }

  //Delete a single record
  @Override
  public int delete(String table, String key){
    System.out.println("Couchbase client: inside delete");
    client.delete(key);
    return 0;
  }

}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































































































































































Deleted Jesse/README.txt~.

1
2
Hey Mike!

<
<




Deleted Jesse/Readme.txt.

1
blah blah 
<


Deleted Jesse/webpage/416Project/sample.txt.