vayacondios-server 0.1.2 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/Gemfile +1 -0
  2. data/app/http_shim.rb +1 -5
  3. data/lib/vayacondios-client.rb +2 -0
  4. data/lib/vayacondios-server.rb +1 -0
  5. data/lib/vayacondios/client/cube_client.rb +39 -0
  6. data/lib/vayacondios/client/itemset.rb +43 -28
  7. data/lib/vayacondios/client/notifier.rb +24 -1
  8. data/lib/vayacondios/client/zabbix_client.rb +148 -0
  9. data/lib/vayacondios/server/handlers/itemset_handler.rb +0 -1
  10. data/lib/vayacondios/server/model/itemset_document.rb +8 -4
  11. data/lib/vayacondios/server/rack/assume_json.rb +13 -0
  12. data/lib/vayacondios/server/rack/extract_methods.rb +11 -1
  13. data/lib/vayacondios/version.rb +1 -1
  14. data/pom.xml +97 -0
  15. data/scripts/hadoop_monitor/configurable.rb +1 -1
  16. data/scripts/hadoop_monitor/hadoop_attempt_scraper.rb +6 -3
  17. data/scripts/hadoop_monitor/hadoop_client.rb +20 -19
  18. data/scripts/hadoop_monitor/hadoop_monitor.rb +3 -3
  19. data/scripts/hadoop_monitor/hadoopable.rb +3 -3
  20. data/scripts/hadoop_monitor/machine_monitor.rb +2 -2
  21. data/spec/client/itemset_spec.rb +8 -8
  22. data/spec/server/itemset_spec.rb +4 -4
  23. data/src/main/java/com/infochimps/util/CurrentClass.java +26 -0
  24. data/src/main/java/com/infochimps/util/DebugUtil.java +38 -0
  25. data/src/main/java/com/infochimps/util/HttpHelper.java +112 -0
  26. data/src/main/java/com/infochimps/vayacondios/ItemSets.java +456 -0
  27. data/src/main/java/com/infochimps/vayacondios/Organization.java +49 -0
  28. data/src/main/java/com/infochimps/vayacondios/PathBuilder.java +13 -0
  29. data/src/main/java/com/infochimps/vayacondios/VCDIntegrationTest.java +68 -0
  30. data/src/main/java/com/infochimps/vayacondios/VayacondiosClient.java +88 -0
  31. data/vayacondios-client.gemspec +2 -2
  32. data/vayacondios-server.gemspec +4 -2
  33. metadata +37 -9
@@ -0,0 +1,49 @@
1
+ package com.infochimps.vayacondios;
2
+
3
+ import java.util.Collection;
4
+
5
+ /**
6
+ * An organization is the last commmon class in the Vayacondios
7
+ * hierarchy between the itemset and stash interface.
8
+ */
9
+ public class Organization extends VayacondiosClient {
10
+ public Organization(PathBuilder delegate) { super(delegate); }
11
+
12
+ public Organization(VayacondiosClient server, String organization) {
13
+ super(server);
14
+ _server = server;
15
+ _organization = organization;
16
+ }
17
+
18
+ //----------------------------------------------------------------------------
19
+ // next in path hierarchy
20
+ //----------------------------------------------------------------------------
21
+
22
+ /**
23
+ * @return new ItemSets path builder for this organization
24
+ */
25
+ public ItemSets itemsets() { return new ItemSets(this); }
26
+
27
+ //----------------------------------------------------------------------------
28
+ // API HTTP path components
29
+ //----------------------------------------------------------------------------
30
+
31
+ protected String urlString(String type, String topic, String id) {
32
+ return urlString(getOrganization(), type, topic, id);
33
+ }
34
+
35
+ protected int getPort() {
36
+ return ((VayacondiosClient)getDelegate()).getPort();
37
+ }
38
+ protected String getServerName() {
39
+ return ((VayacondiosClient)getDelegate()).getServerName();
40
+ }
41
+ String getOrganization() { return _organization; }
42
+
43
+ //----------------------------------------------------------------------------
44
+ // fields
45
+ //----------------------------------------------------------------------------
46
+
47
+ private VayacondiosClient _server;
48
+ private String _organization;
49
+ }
@@ -0,0 +1,13 @@
1
+ package com.infochimps.vayacondios;
2
+
3
+ class PathBuilder {
4
+ public PathBuilder() {}
5
+
6
+ public PathBuilder(PathBuilder delegate) {
7
+ _delegate = delegate;
8
+ }
9
+
10
+ protected PathBuilder getDelegate() { return _delegate; }
11
+
12
+ private PathBuilder _delegate;
13
+ }
@@ -0,0 +1,68 @@
1
+ package com.infochimps.vayacondios;
2
+
3
+ import com.infochimps.vayacondios.VayacondiosClient;
4
+
5
+ import static com.infochimps.util.CurrentClass.getLogger;
6
+
7
+ import static com.infochimps.vayacondios.ItemSets.Item;
8
+ import static com.infochimps.vayacondios.ItemSets.ItemSet;
9
+
10
+ import java.io.IOException;
11
+ import java.util.Arrays;
12
+ import java.util.ArrayList;
13
+ import java.util.Iterator;
14
+ import java.util.List;
15
+
16
+ import org.slf4j.Logger;
17
+
18
+ public class VCDIntegrationTest {
19
+ private static final int VCD_PORT = 8000;
20
+ private static final Logger LOG = getLogger();
21
+
22
+ private static ItemSet newSet() {
23
+ return new VayacondiosClient("localhost", VCD_PORT).
24
+ organization("org").
25
+ itemsets().
26
+ topic("topic").
27
+ itemSet("id");
28
+ }
29
+
30
+ private static void assertEquals(String... expectedStringArr)
31
+ throws IOException {
32
+ List<Item> items = newSet().fetch();
33
+ List<Item> expectedItems = new ArrayList();
34
+ List<Item> copy;
35
+
36
+ for (String exp : expectedStringArr) expectedItems.add(new Item(exp));
37
+
38
+ if (!items.containsAll(expectedItems)) {
39
+ copy = new ArrayList(); copy.addAll(expectedItems);
40
+ LOG.trace("removing items. copy change? " + copy.removeAll(items));
41
+ System.out.println("\033[31mFAIL\033[0m: expected but absent: " + copy);
42
+ }
43
+ if (!expectedItems.containsAll(items)) {
44
+ copy = new ArrayList(); copy.addAll(items);
45
+ LOG.trace("removing items. copy change? " + copy.removeAll(expectedItems));
46
+ System.out.println("\033[31mFAIL\033[0m: unexpected and present: " + copy);
47
+ }
48
+ }
49
+
50
+ public static void main(String argv[]) {
51
+ System.out.println("*** If Vayacondios is not running on port " + VCD_PORT + ", " +
52
+ "this will fail. ***");
53
+ System.out.println("Running Vayacondios integration test...");
54
+
55
+ try {
56
+ newSet().create(Arrays.asList(new Item("foo"), new Item("baz"), new Item("bar"), new Item("bing")));
57
+ assertEquals("foo", "baz", "bar", "bing");
58
+ newSet().update(Arrays.asList(new Item("biff")));
59
+ assertEquals("foo", "baz", "bar", "bing", "biff");
60
+ newSet().remove(Arrays.asList(new Item("biff"), new Item("bar")));
61
+ assertEquals("foo", "baz", "bing");
62
+
63
+ System.out.println("Integration test complete.");
64
+ } catch (Exception ex) {
65
+ ex.printStackTrace();
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,88 @@
1
+ package com.infochimps.vayacondios;
2
+
3
+ import static com.infochimps.util.CurrentClass.getLogger;
4
+
5
+ import com.infochimps.util.CurrentClass;
6
+ import com.infochimps.util.HttpHelper;
7
+
8
+ import java.io.IOException;
9
+ import java.io.BufferedReader;
10
+ import java.nio.charset.Charset;
11
+ import java.util.HashMap;
12
+
13
+ import org.slf4j.Logger;
14
+
15
+ /**
16
+ * VayacondiosClient is the root of the Vayacondios hierarchy. It
17
+ * communicates with a Vayacondios server via its HTTP API. Currently
18
+ * only Vayacondios itemsets are supported.
19
+ */
20
+ public class VayacondiosClient extends PathBuilder {
21
+ public VayacondiosClient(PathBuilder delegate) { super(delegate); }
22
+
23
+ public VayacondiosClient(String serverName, int port) {
24
+ _serverName = serverName;
25
+ _port = port;
26
+ }
27
+
28
+ //----------------------------------------------------------------------------
29
+ // next in path hierarchy
30
+ //----------------------------------------------------------------------------
31
+
32
+ /**
33
+ * @param organization Vayacondios organization. see Vayacondios
34
+ * documentation for details.
35
+ * @return new Organization path builder for this server with the
36
+ * specified orgnanization name
37
+ *
38
+ */
39
+ public Organization organization(String organization) {
40
+ return new Organization(this, organization);
41
+ }
42
+
43
+ //----------------------------------------------------------------------------
44
+ // API HTTP path components
45
+ //----------------------------------------------------------------------------
46
+
47
+ protected String urlString(String organization,
48
+ String type,
49
+ String topic,
50
+ String id) {
51
+ return new StringBuilder().
52
+ append("http://").
53
+ append(getServerName()).
54
+ append(":").
55
+ append(getPort()).
56
+ append("/v1/").
57
+ append(organization).
58
+ append("/").
59
+ append(type).
60
+ append("/").
61
+ append(topic).
62
+ append("/").
63
+ append(id)
64
+ .toString();
65
+ }
66
+
67
+ protected int getPort() { return _port; }
68
+ protected String getServerName() { return _serverName; }
69
+
70
+ //----------------------------------------------------------------------------
71
+ // private methods
72
+ //----------------------------------------------------------------------------
73
+
74
+ protected BufferedReader openUrl(String urlString) throws IOException {
75
+ HashMap headers = new HashMap();
76
+ headers.put("Accept", "*/*");
77
+ return HttpHelper.open(LOG, urlString, headers, Charset.forName("UTF-8"));
78
+ }
79
+
80
+ //----------------------------------------------------------------------------
81
+ // fields
82
+ //----------------------------------------------------------------------------
83
+
84
+ private String _serverName;
85
+ private int _port;
86
+
87
+ private static final Logger LOG = getLogger();
88
+ }
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ['lib']
17
17
 
18
18
  gem.add_dependency('configliere', '>= 0.4.16')
19
- gem.add_dependency('multi_json', '~> 1.1')
20
- gem.add_dependency('gorillib', '~> 0.4.2')
19
+ gem.add_dependency('multi_json', '>= 1.3.6')
20
+ gem.add_dependency('gorillib', '>= 0.4.2')
21
21
 
22
22
  gem.add_development_dependency('rake')
23
23
  gem.add_development_dependency('yard', '>= 0.7')
@@ -16,8 +16,10 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(/^spec/)
17
17
  gem.require_paths = ['lib']
18
18
 
19
- gem.add_dependency('configliere', '>= 0.4.13')
20
- gem.add_dependency('gorillib', '~> 0.4.2')
19
+ gem.add_dependency('configliere', '>= 0.4.16')
20
+ gem.add_dependency('gorillib', '>= 0.4.2')
21
+ gem.add_dependency('multi_json', '>= 1.3.6')
22
+
21
23
  gem.add_dependency('eventmachine', '~> 1.0.0.beta.4')
22
24
  gem.add_dependency('goliath', '~> 1.0')
23
25
  gem.add_dependency('em-http-request', '~> 1.0')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vayacondios-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-12-17 00:00:00.000000000 Z
15
+ date: 2013-03-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: configliere
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ! '>='
23
23
  - !ruby/object:Gem::Version
24
- version: 0.4.13
24
+ version: 0.4.16
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,13 +29,13 @@ dependencies:
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.4.13
32
+ version: 0.4.16
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: gorillib
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  none: false
37
37
  requirements:
38
- - - ~>
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.4.2
41
41
  type: :runtime
@@ -43,9 +43,25 @@ dependencies:
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  none: false
45
45
  requirements:
46
- - - ~>
46
+ - - ! '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: 0.4.2
49
+ - !ruby/object:Gem::Dependency
50
+ name: multi_json
51
+ requirement: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: 1.3.6
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: 1.3.6
49
65
  - !ruby/object:Gem::Dependency
50
66
  name: eventmachine
51
67
  requirement: !ruby/object:Gem::Requirement
@@ -187,9 +203,11 @@ files:
187
203
  - lib/vayacondios-client.rb
188
204
  - lib/vayacondios-server.rb
189
205
  - lib/vayacondios/client/configliere.rb
206
+ - lib/vayacondios/client/cube_client.rb
190
207
  - lib/vayacondios/client/http_client.rb
191
208
  - lib/vayacondios/client/itemset.rb
192
209
  - lib/vayacondios/client/notifier.rb
210
+ - lib/vayacondios/client/zabbix_client.rb
193
211
  - lib/vayacondios/server/errors/bad_request.rb
194
212
  - lib/vayacondios/server/errors/not_found.rb
195
213
  - lib/vayacondios/server/handlers/config_handler.rb
@@ -199,10 +217,12 @@ files:
199
217
  - lib/vayacondios/server/model/document.rb
200
218
  - lib/vayacondios/server/model/event_document.rb
201
219
  - lib/vayacondios/server/model/itemset_document.rb
220
+ - lib/vayacondios/server/rack/assume_json.rb
202
221
  - lib/vayacondios/server/rack/extract_methods.rb
203
222
  - lib/vayacondios/server/rack/path.rb
204
223
  - lib/vayacondios/server/rack/path_validation.rb
205
224
  - lib/vayacondios/version.rb
225
+ - pom.xml
206
226
  - scripts/hadoop_monitor/configurable.rb
207
227
  - scripts/hadoop_monitor/hadoop_attempt_scraper.rb
208
228
  - scripts/hadoop_monitor/hadoop_client.rb
@@ -223,6 +243,14 @@ files:
223
243
  - spec/server/server_spec.rb
224
244
  - spec/spec_helper.rb
225
245
  - spec/support/mongo_cleaner.rb
246
+ - src/main/java/com/infochimps/util/CurrentClass.java
247
+ - src/main/java/com/infochimps/util/DebugUtil.java
248
+ - src/main/java/com/infochimps/util/HttpHelper.java
249
+ - src/main/java/com/infochimps/vayacondios/ItemSets.java
250
+ - src/main/java/com/infochimps/vayacondios/Organization.java
251
+ - src/main/java/com/infochimps/vayacondios/PathBuilder.java
252
+ - src/main/java/com/infochimps/vayacondios/VCDIntegrationTest.java
253
+ - src/main/java/com/infochimps/vayacondios/VayacondiosClient.java
226
254
  - vayacondios-client.gemspec
227
255
  - vayacondios-server.gemspec
228
256
  homepage: https://github.com/infochimps-labs/vayacondios
@@ -239,7 +267,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
267
  version: '0'
240
268
  segments:
241
269
  - 0
242
- hash: 1142154938423914035
270
+ hash: -1849202629108369085
243
271
  required_rubygems_version: !ruby/object:Gem::Requirement
244
272
  none: false
245
273
  requirements:
@@ -248,10 +276,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
276
  version: '0'
249
277
  segments:
250
278
  - 0
251
- hash: 1142154938423914035
279
+ hash: -1849202629108369085
252
280
  requirements: []
253
281
  rubyforge_project:
254
- rubygems_version: 1.8.24
282
+ rubygems_version: 1.8.25
255
283
  signing_key:
256
284
  specification_version: 3
257
285
  summary: Data goes in. The right thing happens