vayacondios-server 0.2.11 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/.travis.yml +2 -0
- data/Gemfile +15 -9
- data/LICENSE.md +2 -6
- data/Procfile +1 -1
- data/README.md +656 -111
- data/Rakefile +89 -6
- data/bin/vcd +10 -0
- data/bin/vcd-server +8 -0
- data/config/database.yml +6 -0
- data/config/spec.example.yml +18 -0
- data/config/vayacondios.example.yml +15 -0
- data/config/vcd-server.rb +37 -0
- data/examples/configuration.rb +56 -0
- data/examples/event_stream.rb +19 -0
- data/examples/simple.rb +61 -0
- data/features/event.feature +319 -0
- data/features/events.feature +208 -0
- data/features/stash.feature +840 -0
- data/features/stashes.feature +492 -0
- data/features/step_definitions/stash_steps.rb +113 -0
- data/features/stream.feature +30 -0
- data/features/support/em.rb +14 -0
- data/features/support/env.rb +13 -0
- data/lib/vayacondios/configuration.rb +63 -0
- data/lib/vayacondios/server/api.rb +126 -0
- data/lib/vayacondios/server/api_options.rb +56 -0
- data/lib/vayacondios/server/configuration.rb +23 -0
- data/lib/vayacondios/server/driver.rb +71 -0
- data/lib/vayacondios/server/drivers/mongo.rb +126 -0
- data/lib/vayacondios/server/handlers/document_handler.rb +81 -0
- data/lib/vayacondios/server/handlers/event_handler.rb +31 -26
- data/lib/vayacondios/server/handlers/events_handler.rb +31 -0
- data/lib/vayacondios/server/handlers/stash_handler.rb +69 -0
- data/lib/vayacondios/server/handlers/stashes_handler.rb +49 -0
- data/lib/vayacondios/server/handlers/stream_handler.rb +39 -0
- data/lib/vayacondios/server/models/document.rb +87 -0
- data/lib/vayacondios/server/models/event.rb +198 -0
- data/lib/vayacondios/server/models/stash.rb +100 -0
- data/lib/vayacondios/server.rb +35 -0
- data/lib/vayacondios-server.rb +19 -13
- data/lib/vayacondios.rb +22 -0
- data/pom.xml +124 -4
- data/spec/configuration_spec.rb +41 -0
- data/spec/server/api_options_spec.rb +32 -0
- data/spec/server/api_spec.rb +279 -0
- data/spec/server/configuration_spec.rb +27 -0
- data/spec/server/drivers/mongo_spec.rb +107 -0
- data/spec/server/handlers/event_handler_spec.rb +62 -0
- data/spec/server/handlers/events_handler_spec.rb +51 -0
- data/spec/server/handlers/stash_handler_spec.rb +68 -0
- data/spec/server/handlers/stashes_handler_spec.rb +50 -0
- data/spec/server/handlers/stream_handler_spec.rb +5 -0
- data/spec/server/models/document_spec.rb +9 -0
- data/spec/server/models/event_spec.rb +185 -0
- data/spec/server/models/stash_spec.rb +95 -0
- data/spec/spec_helper.rb +23 -3
- data/spec/support/database_helper.rb +42 -0
- data/spec/support/log_helper.rb +19 -0
- data/spec/support/shared_context_for_events.rb +22 -0
- data/spec/support/shared_context_for_stashes.rb +24 -0
- data/spec/support/shared_examples_for_handlers.rb +32 -0
- data/src/main/java/com/infochimps/vayacondios/BaseClient.java +342 -0
- data/src/main/java/com/infochimps/vayacondios/HTTPClient.java +426 -0
- data/src/main/java/com/infochimps/vayacondios/VayacondiosClient.java +487 -65
- data/src/main/java/com/infochimps/vayacondios/test/IntegrationTest.java +3 -0
- data/src/test/java/com/infochimps/vayacondios/BaseClientTest.java +50 -0
- data/src/test/java/com/infochimps/vayacondios/HTTPClientIT.java +267 -0
- data/vayacondios-server.gemspec +9 -9
- metadata +127 -122
- checksums.yaml +0 -15
- data/.rspec +0 -2
- data/.yardopts +0 -10
- data/Guardfile +0 -41
- data/app/http_shim.rb +0 -71
- data/bin/vcd.sh +0 -27
- data/config/http_shim.rb +0 -43
- data/config/vayacondios.example.yaml +0 -7
- data/config/vayacondios.yaml +0 -7
- data/examples/java/ItemSetTest.java +0 -76
- data/lib/tasks/publish.rake +0 -23
- data/lib/tasks/spec.rake +0 -11
- data/lib/tasks/yard.rake +0 -2
- data/lib/vayacondios/client/config.rb +0 -7
- data/lib/vayacondios/client/configliere.rb +0 -38
- data/lib/vayacondios/client/cube_client.rb +0 -39
- data/lib/vayacondios/client/http_client.rb +0 -49
- data/lib/vayacondios/client/itemset.rb +0 -130
- data/lib/vayacondios/client/legacy_switch.rb +0 -43
- data/lib/vayacondios/client/notifier.rb +0 -123
- data/lib/vayacondios/client/zabbix_client.rb +0 -148
- data/lib/vayacondios/legacy_switch.rb +0 -43
- data/lib/vayacondios/server/errors/bad_request.rb +0 -6
- data/lib/vayacondios/server/errors/not_found.rb +0 -6
- data/lib/vayacondios/server/handlers/config_handler.rb +0 -32
- data/lib/vayacondios/server/handlers/itemset_handler.rb +0 -60
- data/lib/vayacondios/server/legacy_switch.rb +0 -43
- data/lib/vayacondios/server/model/config_document.rb +0 -89
- data/lib/vayacondios/server/model/document.rb +0 -25
- data/lib/vayacondios/server/model/event_document.rb +0 -94
- data/lib/vayacondios/server/model/itemset_document.rb +0 -126
- data/lib/vayacondios/server/rack/extract_methods.rb +0 -35
- data/lib/vayacondios/server/rack/jsonize.rb +0 -43
- data/lib/vayacondios/server/rack/params.rb +0 -50
- data/lib/vayacondios/server/rack/path.rb +0 -23
- data/lib/vayacondios/server/rack/path_validation.rb +0 -22
- data/lib/vayacondios/version.rb +0 -3
- data/lib/vayacondios-client.rb +0 -22
- data/scripts/hadoop_monitor/configurable.rb +0 -66
- data/scripts/hadoop_monitor/hadoop_attempt_scraper.rb +0 -45
- data/scripts/hadoop_monitor/hadoop_client.rb +0 -273
- data/scripts/hadoop_monitor/hadoop_monitor.rb +0 -101
- data/scripts/hadoop_monitor/hadoopable.rb +0 -65
- data/scripts/hadoop_monitor/machine_monitor.rb +0 -115
- data/scripts/s3_cataloger/buckets +0 -33
- data/scripts/s3_cataloger/foreach_bucket +0 -88
- data/scripts/s3_cataloger/parse_ls.py +0 -391
- data/spec/client/itemset_legacy_spec.rb +0 -55
- data/spec/client/itemset_spec.rb +0 -60
- data/spec/client/notifier_spec.rb +0 -120
- data/spec/server/config_spec.rb +0 -113
- data/spec/server/event_spec.rb +0 -103
- data/spec/server/itemset_legacy_spec.rb +0 -320
- data/spec/server/itemset_spec.rb +0 -317
- data/spec/server/rack/extract_methods_spec.rb +0 -60
- data/spec/server/rack/path_spec.rb +0 -36
- data/spec/server/rack/path_validation_spec.rb +0 -22
- data/spec/server/server_spec.rb +0 -20
- data/spec/support/mongo_cleaner.rb +0 -32
- data/src/main/java/ItemSetTest.java +0 -76
- data/src/main/java/com/infochimps/util/CurrentClass.java +0 -26
- data/src/main/java/com/infochimps/util/DebugUtil.java +0 -38
- data/src/main/java/com/infochimps/util/HttpHelper.java +0 -181
- data/src/main/java/com/infochimps/vayacondios/ItemSets.java +0 -373
- data/src/main/java/com/infochimps/vayacondios/LinkToVCD.java +0 -18
- data/src/main/java/com/infochimps/vayacondios/MemoryVCDShim.java +0 -84
- data/src/main/java/com/infochimps/vayacondios/Organization.java +0 -62
- data/src/main/java/com/infochimps/vayacondios/PathBuilder.java +0 -13
- data/src/main/java/com/infochimps/vayacondios/StandardVCDLink.java +0 -218
- data/src/main/java/com/infochimps/vayacondios/VCDIntegrationTest.java +0 -108
- data/src/test/java/com/infochimps/vayacondios/TestVayacondiosInMemory.java +0 -78
- data/vayacondios-client.gemspec +0 -25
@@ -1,218 +0,0 @@
|
|
1
|
-
package com.infochimps.vayacondios;
|
2
|
-
import com.google.gson.Gson;
|
3
|
-
import com.google.gson.GsonBuilder;
|
4
|
-
import com.google.gson.JsonArray;
|
5
|
-
import com.google.gson.JsonElement;
|
6
|
-
import com.google.gson.JsonIOException;
|
7
|
-
import com.google.gson.JsonObject;
|
8
|
-
import com.google.gson.JsonParser;
|
9
|
-
import com.google.gson.JsonPrimitive;
|
10
|
-
import com.google.gson.JsonParseException;
|
11
|
-
import com.google.gson.JsonSerializer;
|
12
|
-
import com.google.gson.JsonSerializationContext;
|
13
|
-
import com.google.gson.JsonSyntaxException;
|
14
|
-
|
15
|
-
|
16
|
-
import java.io.BufferedReader;
|
17
|
-
import java.io.FileNotFoundException;
|
18
|
-
import java.io.InputStream;
|
19
|
-
import java.io.OutputStream;
|
20
|
-
import java.io.IOException;
|
21
|
-
import java.net.HttpURLConnection;
|
22
|
-
import java.nio.charset.Charset;
|
23
|
-
import java.util.ArrayList;
|
24
|
-
import java.util.HashMap;
|
25
|
-
import java.util.List;
|
26
|
-
import java.util.Map;
|
27
|
-
|
28
|
-
import java.net.URL;
|
29
|
-
|
30
|
-
import org.slf4j.Logger;
|
31
|
-
|
32
|
-
import com.infochimps.util.DebugUtil;
|
33
|
-
import com.infochimps.util.HttpHelper;
|
34
|
-
import static com.infochimps.util.CurrentClass.getLogger;
|
35
|
-
import static com.infochimps.vayacondios.ItemSets.Item;
|
36
|
-
|
37
|
-
public class StandardVCDLink extends LinkToVCD {
|
38
|
-
public List<Item> fetch(String topic, String id) throws IOException {
|
39
|
-
BufferedReader reader = null;
|
40
|
-
try {
|
41
|
-
reader = openUrl(getParent().urlString(PATH_COMPONENT, topic, id));
|
42
|
-
} catch (FileNotFoundException ex) {
|
43
|
-
// In the case of a 404, return an empty set.
|
44
|
-
return new ArrayList();
|
45
|
-
}
|
46
|
-
String line = reader.readLine();
|
47
|
-
JsonElement response;
|
48
|
-
JsonElement itemSet;
|
49
|
-
|
50
|
-
ArrayList<Item> result = new ArrayList<Item>();
|
51
|
-
|
52
|
-
// assume Vayacondios response comes in a single line
|
53
|
-
if (line != null &&
|
54
|
-
(itemSet = VCD_HANDLER.extractContents(PARSER.parse(line))) != null) {
|
55
|
-
for (JsonElement elem : itemSet.getAsJsonArray()) {
|
56
|
-
if (!elem.isJsonPrimitive()) {
|
57
|
-
LOG.warn("ignoring non-primitive in itemset: " + elem);
|
58
|
-
continue;
|
59
|
-
}
|
60
|
-
|
61
|
-
JsonPrimitive item = elem.getAsJsonPrimitive();
|
62
|
-
if (item.isBoolean()) result.add(new Item(item.getAsBoolean()));
|
63
|
-
else if (item.isNumber()) result.add(new Item(item.getAsNumber()));
|
64
|
-
else if (item.isString()) result.add(new Item(item.getAsString()));
|
65
|
-
|
66
|
-
else LOG.warn("ignoring unrecognized type in itemset: " + item);
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
if ((line = reader.readLine()) != null)
|
71
|
-
LOG.warn("expected eof but saw " + line);
|
72
|
-
|
73
|
-
reader.close();
|
74
|
-
|
75
|
-
return result;
|
76
|
-
}
|
77
|
-
|
78
|
-
public void mutate(String method,
|
79
|
-
String topic,
|
80
|
-
String id,
|
81
|
-
List<Item> items) throws IOException {
|
82
|
-
|
83
|
-
// serialize the items
|
84
|
-
String body = VCD_HANDLER.wrapContents(items);
|
85
|
-
// connect to our standard path
|
86
|
-
URL url = new URL(getParent().urlString(PATH_COMPONENT, topic, id));
|
87
|
-
HttpURLConnection connection = (HttpURLConnection)
|
88
|
-
((Boolean.valueOf(System.getProperty("ics.http.use_charles"))) ?
|
89
|
-
url.openConnection(DebugUtil.useCharles()) : url.openConnection());
|
90
|
-
|
91
|
-
// configure connection
|
92
|
-
connection.setDoOutput(true);
|
93
|
-
|
94
|
-
// NOTE: Uncommenting this (and not calling
|
95
|
-
// connection.getInputStream()) causes Java to hang without
|
96
|
-
// sending its payload.
|
97
|
-
|
98
|
-
// connection.setDoInput(false);
|
99
|
-
|
100
|
-
if (method.equals("DELETE")) {
|
101
|
-
connection.setRequestMethod("PUT");
|
102
|
-
connection.setRequestProperty("X-Method", "DELETE");
|
103
|
-
} else if (method.equals("PATCH")) {
|
104
|
-
connection.setRequestMethod("PUT");
|
105
|
-
connection.setRequestProperty("X-Method", "PATCH");
|
106
|
-
} else connection.setRequestMethod(method);
|
107
|
-
connection.setRequestProperty("Content-Type", "application/json");
|
108
|
-
connection.setRequestProperty("Accept", "*/*");
|
109
|
-
connection.setRequestProperty("Content-Length",
|
110
|
-
Integer.toString(body.getBytes().length));
|
111
|
-
connection.setUseCaches(false);
|
112
|
-
|
113
|
-
LOG.debug("sending: " + body);
|
114
|
-
LOG.debug("via " +
|
115
|
-
connection.getRequestMethod() +
|
116
|
-
" to " +
|
117
|
-
getParent().urlString(PATH_COMPONENT, topic, id));
|
118
|
-
|
119
|
-
// connect and write
|
120
|
-
OutputStream os = connection.getOutputStream();
|
121
|
-
os.write(body.getBytes("UTF-8"));
|
122
|
-
os.flush();
|
123
|
-
os.close();
|
124
|
-
|
125
|
-
// ignore reponse
|
126
|
-
InputStream is = connection.getInputStream();
|
127
|
-
|
128
|
-
LOG.trace("ignoring response from Vayacondios.");
|
129
|
-
byte buf[] = new byte[256];
|
130
|
-
while (is.read(buf) != -1);
|
131
|
-
LOG.trace("response ignored.");
|
132
|
-
is.close();
|
133
|
-
|
134
|
-
// fin.
|
135
|
-
connection.disconnect();
|
136
|
-
}
|
137
|
-
|
138
|
-
//----------------------------------------------------------------------------
|
139
|
-
|
140
|
-
public static void forceLegacy(boolean vcdLegacy) {
|
141
|
-
LOG.info("forcing vayacondios {} mode", vcdLegacy ? "legacy" : "standard");
|
142
|
-
|
143
|
-
VCD_HANDLER = vcdLegacy ?
|
144
|
-
new LegacyContentsHandler() : new StandardContentsHandler();
|
145
|
-
}
|
146
|
-
|
147
|
-
//----------------------------------------------------------------------------
|
148
|
-
|
149
|
-
private BufferedReader openUrl(String urlString) throws IOException {
|
150
|
-
HashMap headers = new HashMap();
|
151
|
-
headers.put("Accept", "*/*");
|
152
|
-
return HttpHelper.open(LOG, urlString, headers, Charset.forName("UTF-8"));
|
153
|
-
}
|
154
|
-
|
155
|
-
private static final Gson GSON = new GsonBuilder().
|
156
|
-
registerTypeAdapter(Item.class, new Item.Serializer()).
|
157
|
-
create();
|
158
|
-
private static final JsonParser PARSER = new JsonParser();
|
159
|
-
private static final Logger LOG = getLogger();
|
160
|
-
private static final String PATH_COMPONENT = "itemset";
|
161
|
-
|
162
|
-
private static LegacySwitch VCD_HANDLER = new StandardContentsHandler();
|
163
|
-
|
164
|
-
//----------------------------------------------------------------------------
|
165
|
-
|
166
|
-
private static interface LegacySwitch {
|
167
|
-
String wrapContents(List<Item> items);
|
168
|
-
JsonArray extractContents(JsonElement response);
|
169
|
-
}
|
170
|
-
|
171
|
-
private static class LegacyContentsHandler implements LegacySwitch {
|
172
|
-
@Override
|
173
|
-
public String wrapContents(List<Item> items) {
|
174
|
-
String json = GSON.toJson(items);
|
175
|
-
LOG.trace("results of wrapping with legacy handler: {}", json);
|
176
|
-
return json;
|
177
|
-
}
|
178
|
-
@Override
|
179
|
-
public JsonArray extractContents(JsonElement response) {
|
180
|
-
if (response.isJsonArray()) {
|
181
|
-
return response.getAsJsonArray();
|
182
|
-
} else { return null; }
|
183
|
-
}
|
184
|
-
}
|
185
|
-
|
186
|
-
private static class StandardContentsHandler implements LegacySwitch {
|
187
|
-
@Override
|
188
|
-
public String wrapContents(final List<Item> items) {
|
189
|
-
// not at all sure why GSON is returning null given a
|
190
|
-
// Map<String,List<Item>> all of the sudden, but it seems to
|
191
|
-
// work on a Map<String,List<String>>, so here we go.
|
192
|
-
Map<String,List<String>> contents =
|
193
|
-
new HashMap<String,List<String>>();
|
194
|
-
List<String> strItems = new ArrayList<String>();
|
195
|
-
for (Item item : items) {
|
196
|
-
strItems.add(item.getObject().toString());
|
197
|
-
}
|
198
|
-
contents.put("contents", strItems);
|
199
|
-
LOG.trace("contents: {}", contents);
|
200
|
-
String json = GSON.toJson(contents);
|
201
|
-
LOG.trace("results of wrapping with standard handler: {}", json);
|
202
|
-
return json;
|
203
|
-
}
|
204
|
-
@Override
|
205
|
-
public JsonArray extractContents(JsonElement response) {
|
206
|
-
JsonElement itemSet;
|
207
|
-
|
208
|
-
if (response.isJsonObject()) {
|
209
|
-
if ((itemSet = response.getAsJsonObject().get("contents"))
|
210
|
-
.isJsonArray()) {
|
211
|
-
return itemSet.getAsJsonArray();
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
return null;
|
216
|
-
}
|
217
|
-
}
|
218
|
-
}
|
@@ -1,108 +0,0 @@
|
|
1
|
-
package com.infochimps.vayacondios;
|
2
|
-
|
3
|
-
import com.infochimps.vayacondios.VayacondiosClient;
|
4
|
-
import com.infochimps.vayacondios.StandardVCDLink;
|
5
|
-
|
6
|
-
import static com.infochimps.util.CurrentClass.getLogger;
|
7
|
-
|
8
|
-
import static com.infochimps.vayacondios.ItemSets.Item;
|
9
|
-
import static com.infochimps.vayacondios.ItemSets.ItemSet;
|
10
|
-
import com.infochimps.vayacondios.ItemSets;
|
11
|
-
|
12
|
-
import java.io.IOException;
|
13
|
-
import java.util.Arrays;
|
14
|
-
import java.util.ArrayList;
|
15
|
-
import java.util.Iterator;
|
16
|
-
import java.util.List;
|
17
|
-
|
18
|
-
import org.slf4j.Logger;
|
19
|
-
|
20
|
-
public class VCDIntegrationTest {
|
21
|
-
private static final int VCD_PORT = 8000;
|
22
|
-
private static final Logger LOG = getLogger();
|
23
|
-
|
24
|
-
public static void setUp() {
|
25
|
-
// This will default to false when the property is null, which is
|
26
|
-
// what we happen to want.
|
27
|
-
boolean legacyMode =
|
28
|
-
Boolean.valueOf(System.getProperty("vayacondios.legacy"));
|
29
|
-
LOG.info("Using Vayacondios {} mode", legacyMode ? "legacy" : "standard");
|
30
|
-
StandardVCDLink.forceLegacy(legacyMode);
|
31
|
-
}
|
32
|
-
private static ItemSets itemSets() {
|
33
|
-
return new VayacondiosClient("localhost", VCD_PORT).
|
34
|
-
organization("org").
|
35
|
-
itemsets();
|
36
|
-
}
|
37
|
-
|
38
|
-
private static List<Item> buildItemList(String items[]) {
|
39
|
-
List<Item> result = new ArrayList<Item>();
|
40
|
-
for (String s : items) result.add(new Item(s));
|
41
|
-
return result;
|
42
|
-
}
|
43
|
-
|
44
|
-
private static List<String> getStrings(List<Item> items) {
|
45
|
-
List<String> result = new ArrayList<String>();
|
46
|
-
for (Item i : items) result.add(i.getAsString());
|
47
|
-
return result;
|
48
|
-
}
|
49
|
-
|
50
|
-
private static List<String> fetch() throws IOException {
|
51
|
-
return getStrings(itemSets().fetch("topic", "id"));
|
52
|
-
}
|
53
|
-
|
54
|
-
private static void create(String... items) throws IOException {
|
55
|
-
itemSets().create("topic", "id", buildItemList(items));
|
56
|
-
}
|
57
|
-
|
58
|
-
private static void remove(String... items) throws IOException {
|
59
|
-
itemSets().remove("topic", "id", buildItemList(items));
|
60
|
-
}
|
61
|
-
|
62
|
-
private static void update(String... items) throws IOException {
|
63
|
-
itemSets().update("topic", "id", buildItemList(items));
|
64
|
-
}
|
65
|
-
|
66
|
-
private static void assertEquals(String... expectedArr)
|
67
|
-
throws IOException {
|
68
|
-
List<String> items = fetch();
|
69
|
-
List<String> copy = new ArrayList<String>();
|
70
|
-
List<String> expected = Arrays.asList(expectedArr);
|
71
|
-
|
72
|
-
if (!items.containsAll(expected)) {
|
73
|
-
copy = new ArrayList(); copy.addAll(expected);
|
74
|
-
LOG.trace("removing items. copy change? " + copy.removeAll(items));
|
75
|
-
System.out.println("\033[31mFAIL\033[0m: expected but absent: " + copy);
|
76
|
-
} else
|
77
|
-
System.out.println("\033[32mSUCCESS\033[0m: all expected items present");
|
78
|
-
if (!expected.containsAll(items)) {
|
79
|
-
copy = new ArrayList(); copy.addAll(items);
|
80
|
-
LOG.trace("removing items. copy change? " + copy.removeAll(expected));
|
81
|
-
System.out.println("\033[31mFAIL\033[0m: unexpected and present: " + copy);
|
82
|
-
} else
|
83
|
-
System.out.println("\033[32mSUCCESS\033[0m: no unexpected items present");
|
84
|
-
}
|
85
|
-
|
86
|
-
public static void main(String argv[]) {
|
87
|
-
System.out.println("*** If Vayacondios is not running on port " + VCD_PORT + ", " +
|
88
|
-
"this will fail. ***");
|
89
|
-
System.out.println("Running Vayacondios integration test...");
|
90
|
-
|
91
|
-
setUp();
|
92
|
-
|
93
|
-
try {
|
94
|
-
create("foo", "baz", "bar", "bing");
|
95
|
-
assertEquals("foo", "baz", "bar", "bing");
|
96
|
-
|
97
|
-
update("biff");
|
98
|
-
assertEquals("foo", "baz", "bar", "bing", "biff");
|
99
|
-
|
100
|
-
remove("biff", "bar");
|
101
|
-
assertEquals("foo", "baz", "bing");
|
102
|
-
|
103
|
-
System.out.println("Integration test complete.");
|
104
|
-
} catch (Exception ex) {
|
105
|
-
ex.printStackTrace();
|
106
|
-
}
|
107
|
-
}
|
108
|
-
}
|
@@ -1,78 +0,0 @@
|
|
1
|
-
package com.infochimps.vayacondios;
|
2
|
-
|
3
|
-
import com.infochimps.vayacondios.VayacondiosClient;
|
4
|
-
|
5
|
-
import static com.infochimps.util.CurrentClass.getLogger;
|
6
|
-
|
7
|
-
import com.infochimps.vayacondios.MemoryVCDShim;
|
8
|
-
import static com.infochimps.vayacondios.ItemSets.Item;
|
9
|
-
import static com.infochimps.vayacondios.ItemSets.ItemSet;
|
10
|
-
import com.infochimps.vayacondios.ItemSets;
|
11
|
-
|
12
|
-
import java.io.IOException;
|
13
|
-
import java.util.Arrays;
|
14
|
-
import java.util.ArrayList;
|
15
|
-
import java.util.Iterator;
|
16
|
-
import java.util.List;
|
17
|
-
|
18
|
-
import static org.junit.Assert.assertEquals;
|
19
|
-
import org.junit.After;
|
20
|
-
import org.junit.Before;
|
21
|
-
import org.junit.Test;
|
22
|
-
import org.junit.Ignore;
|
23
|
-
import org.junit.runner.RunWith;
|
24
|
-
import org.junit.runners.JUnit4;
|
25
|
-
|
26
|
-
import org.slf4j.Logger;
|
27
|
-
|
28
|
-
@RunWith(JUnit4.class)
|
29
|
-
public class TestVayacondiosInMemory {
|
30
|
-
@Before
|
31
|
-
public void setup() {
|
32
|
-
_itemSets = new VayacondiosClient("localhost", VCD_PORT).
|
33
|
-
organization("org").
|
34
|
-
itemsets(new MemoryVCDShim());
|
35
|
-
}
|
36
|
-
|
37
|
-
@Test
|
38
|
-
public void testInMemVCD() throws Exception {
|
39
|
-
create("foo", "baz", "bar", "bing");
|
40
|
-
assertEquals(buildItemList("foo", "baz", "bar", "bing"), fetch());
|
41
|
-
|
42
|
-
update("biff");
|
43
|
-
assertEquals(buildItemList("foo", "baz", "bar", "bing", "biff"), fetch());
|
44
|
-
|
45
|
-
remove("biff", "bar");
|
46
|
-
assertEquals(buildItemList("foo", "baz", "bing"), fetch());
|
47
|
-
}
|
48
|
-
|
49
|
-
private ItemSets itemSets() {
|
50
|
-
return _itemSets;
|
51
|
-
}
|
52
|
-
|
53
|
-
private static List<Item> buildItemList(String... itemNames) {
|
54
|
-
List<Item> result = new ArrayList<Item>();
|
55
|
-
for (String s : itemNames) result.add(new Item(s));
|
56
|
-
return result;
|
57
|
-
}
|
58
|
-
|
59
|
-
private List<Item> fetch() throws IOException {
|
60
|
-
return itemSets().fetch("topic", "id");
|
61
|
-
}
|
62
|
-
|
63
|
-
private void create(String... items) throws IOException {
|
64
|
-
itemSets().create("topic", "id", buildItemList(items));
|
65
|
-
}
|
66
|
-
|
67
|
-
private void remove(String... items) throws IOException {
|
68
|
-
itemSets().remove("topic", "id", buildItemList(items));
|
69
|
-
}
|
70
|
-
|
71
|
-
private void update(String... items) throws IOException {
|
72
|
-
itemSets().update("topic", "id", buildItemList(items));
|
73
|
-
}
|
74
|
-
|
75
|
-
private static final int VCD_PORT = 8000;
|
76
|
-
private static final Logger LOG = getLogger();
|
77
|
-
private ItemSets _itemSets;
|
78
|
-
}
|
data/vayacondios-client.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
$:.push File.expand_path('../lib', __FILE__)
|
4
|
-
require 'vayacondios/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = 'vayacondios-client'
|
8
|
-
gem.version = Vayacondios::VERSION
|
9
|
-
gem.authors = ['Philip (flip) Kromer', 'Travis Dempsey', 'Huston Hoburg', 'Logan Lowell']
|
10
|
-
gem.homepage = 'https://github.com/infochimps-labs/vayacondios'
|
11
|
-
gem.summary = 'Data goes in. The right thing happens'
|
12
|
-
gem.description = "Simple enough to use in a shell script, performant enough to use everywhere. Dios mío! Record that metric, ese!"
|
13
|
-
|
14
|
-
gem.files = `git ls-files -- lib | grep client`.split("\n")
|
15
|
-
gem.test_files = `git ls-files -- spec | grep client`.split("\n")
|
16
|
-
gem.require_paths = ['lib']
|
17
|
-
|
18
|
-
gem.add_dependency('configliere', '>= 0.4.16')
|
19
|
-
gem.add_dependency('multi_json', '>= 1.3.6')
|
20
|
-
gem.add_dependency('gorillib', '>= 0.4.2')
|
21
|
-
|
22
|
-
gem.add_development_dependency('rake')
|
23
|
-
gem.add_development_dependency('yard', '>= 0.7')
|
24
|
-
gem.add_development_dependency('rspec', '>= 2.8')
|
25
|
-
end
|