embulk-output-mailchimp 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88a7c2c34660acc5f41bae67c49ef51bf6da4623
4
- data.tar.gz: 0876a7e5d771137162eebd468128b85e22717257
3
+ metadata.gz: c7ffeeb484184fcbcb739aef1c871a0c915fca74
4
+ data.tar.gz: ab5372d39822ac2c231945f1360611ed83f555ec
5
5
  SHA512:
6
- metadata.gz: 3bf58d25c81e9ad92cd69a81146b57d87aa771cdfa1d9d1c5045824eb694fa88bfde080f88d3bc13d4d3790a1a9f3fbb8cc2c7ae6fb34ae7a2d9f7b7956f2d3e
7
- data.tar.gz: 02045e97f6750c51287e2f56ccc96b7a0ffc406153dd4e39a9ff5e5ef8b2416a2e5c4a9e66c20bad1a09deaf1610c3b88c05d6512afb9a437947b1fe6ba76d2c
6
+ metadata.gz: ff9ea7f57503ac6149b87fb78a67200cfc59fde7fbf66e1bb632d660ab5480a5f4a9e50ddd8d94bdd9d6a4ec2a8b5dc9ee85f4f2c6b1c4f4041e915a991d6483
7
+ data.tar.gz: 15126516099f6bb739522ec13e9dfcda26ed365a0f686e5e7d9fe7c3dcb37d68cbe97e14a6a760acfa13cfa8c933b20e9f7dad36c5505846bda60817dcb0dde7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.3.13 - 2017-06-16
2
+ - Upgraded `embulk-base-restclient` to v0.5.3 and fixed hang job [#28](https://github.com/treasure-data/embulk-output-mailchimp/pull/28)
3
+
1
4
  ## 0.3.12 - 2017-06-13
2
5
  - Fixed NPE while reading JSON data [#27](https://github.com/treasure-data/embulk-output-mailchimp/pull/27)
3
6
 
data/build.gradle CHANGED
@@ -18,7 +18,7 @@ configurations {
18
18
  provided
19
19
  }
20
20
 
21
- version = "0.3.12"
21
+ version = "0.3.13"
22
22
 
23
23
  sourceCompatibility = 1.7
24
24
  targetCompatibility = 1.7
@@ -26,8 +26,8 @@ targetCompatibility = 1.7
26
26
  dependencies {
27
27
  compile "org.embulk:embulk-core:0.8.15"
28
28
  provided "org.embulk:embulk-core:0.8.15"
29
- compile "org.embulk.base.restclient:embulk-base-restclient:0.5.2"
30
- compile "org.embulk.base.restclient:embulk-util-retryhelper-jetty92:0.5.2"
29
+ compile "org.embulk.base.restclient:embulk-base-restclient:0.5.3"
30
+ compile "org.embulk.base.restclient:embulk-util-retryhelper-jetty92:0.5.3"
31
31
  // compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
32
32
 
33
33
  testCompile "junit:junit:4.+"
@@ -140,8 +140,8 @@ public abstract class MailChimpAbstractRecordBuffer
140
140
  catch (JsonProcessingException jpe) {
141
141
  throw new DataException(jpe);
142
142
  }
143
- finally {
144
- cleanUp();
143
+ catch (Exception ex) {
144
+ throw Throwables.propagate(ex);
145
145
  }
146
146
  }
147
147
 
@@ -202,11 +202,6 @@ public abstract class MailChimpAbstractRecordBuffer
202
202
  return categories;
203
203
  }
204
204
 
205
- /**
206
- * Clean up.
207
- */
208
- abstract void cleanUp();
209
-
210
205
  /**
211
206
  * Push payload data to MailChimp API and get @{@link ReportResponse}
212
207
  *
@@ -31,7 +31,6 @@ public class MailChimpHttpClient
31
31
  private final ObjectMapper jsonMapper = new ObjectMapper()
32
32
  .configure(com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, false)
33
33
  .configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
34
- private Jetty92RetryHelper retryHelper;
35
34
 
36
35
  /**
37
36
  * Instantiates a new Mailchimp http client.
@@ -40,17 +39,6 @@ public class MailChimpHttpClient
40
39
  */
41
40
  public MailChimpHttpClient(MailChimpOutputPluginDelegate.PluginTask task)
42
41
  {
43
- retryHelper = createRetryHelper(task);
44
- }
45
-
46
- /**
47
- * Close @{@link Jetty92RetryHelper} connection
48
- */
49
- public void close()
50
- {
51
- if (retryHelper != null) {
52
- retryHelper.close();
53
- }
54
42
  }
55
43
 
56
44
  public JsonNode sendRequest(final String endpoint, final HttpMethod method,
@@ -62,44 +50,50 @@ public class MailChimpHttpClient
62
50
  public JsonNode sendRequest(final String endpoint, final HttpMethod method, final String content,
63
51
  final MailChimpOutputPluginDelegate.PluginTask task)
64
52
  {
65
- final String authorizationHeader = getAuthorizationHeader(task);
53
+ try (final Jetty92RetryHelper retryHelper = createRetryHelper(task)) {
54
+ final String authorizationHeader = getAuthorizationHeader(task);
66
55
 
67
- String responseBody = retryHelper.requestWithRetry(
68
- new StringJetty92ResponseEntityReader(task.getTimeoutMillis()),
69
- new Jetty92SingleRequester()
70
- {
71
- @Override
72
- public void requestOnce(HttpClient client, Response.Listener responseListener)
56
+ String responseBody = retryHelper.requestWithRetry(
57
+ new StringJetty92ResponseEntityReader(task.getTimeoutMillis()),
58
+ new Jetty92SingleRequester()
73
59
  {
74
- Request request = client
75
- .newRequest(endpoint)
76
- .accept("application/json")
77
- .method(method);
78
- if (method == HttpMethod.POST || method == HttpMethod.PUT) {
79
- request.content(new StringContentProvider(content), "application/json;utf-8");
60
+ @Override
61
+ public void requestOnce(HttpClient client, Response.Listener responseListener)
62
+ {
63
+ Request request = client
64
+ .newRequest(endpoint)
65
+ .accept("application/json")
66
+ .method(method);
67
+ if (method == HttpMethod.POST || method == HttpMethod.PUT) {
68
+ request.content(new StringContentProvider(content), "application/json;utf-8");
69
+ }
70
+
71
+ if (!authorizationHeader.isEmpty()) {
72
+ request.header("Authorization", authorizationHeader);
73
+ }
74
+ request.send(responseListener);
80
75
  }
81
76
 
82
- if (!authorizationHeader.isEmpty()) {
83
- request.header("Authorization", authorizationHeader);
84
- }
85
- request.send(responseListener);
86
- }
77
+ @Override
78
+ public boolean isResponseStatusToRetry(Response response)
79
+ {
80
+ int status = response.getStatus();
87
81
 
88
- @Override
89
- public boolean isResponseStatusToRetry(Response response)
90
- {
91
- int status = response.getStatus();
82
+ if (status == 404) {
83
+ LOG.error("Exception occurred while sending request: {}", response.getReason());
84
+ throw new ConfigException("The `list id` could not be found.");
85
+ }
92
86
 
93
- if (status == 404) {
94
- LOG.error("Exception occurred while sending request: {}", response.getReason());
95
- throw new ConfigException("The `list id` could not be found.");
87
+ return status == 429 || status / 100 != 4;
96
88
  }
89
+ });
97
90
 
98
- return status == 429 || status / 100 != 4;
99
- }
100
- });
101
-
102
- return responseBody != null && !responseBody.isEmpty() ? parseJson(responseBody) : MissingNode.getInstance();
91
+ return responseBody != null && !responseBody.isEmpty() ? parseJson(responseBody) : MissingNode.getInstance();
92
+ }
93
+ catch (Exception ex) {
94
+ LOG.info("Exception occurred while sending request.");
95
+ throw Throwables.propagate(ex);
96
+ }
103
97
  }
104
98
 
105
99
  private JsonNode parseJson(final String json)
@@ -48,9 +48,13 @@ public class MailChimpRecordBuffer extends MailChimpAbstractRecordBuffer
48
48
  }
49
49
 
50
50
  @Override
51
- void cleanUp()
51
+ public void finish()
52
+ {
53
+ }
54
+
55
+ @Override
56
+ public void close()
52
57
  {
53
- client.close();
54
58
  }
55
59
 
56
60
  /**
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-mailchimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thang Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-13 00:00:00.000000000 Z
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -88,9 +88,9 @@ files:
88
88
  - test/embulk/output/test_mailchimp.rb
89
89
  - test/override_assert_raise.rb
90
90
  - test/run-test.rb
91
- - classpath/embulk-base-restclient-0.5.2.jar
92
- - classpath/embulk-output-mailchimp-0.3.12.jar
93
- - classpath/embulk-util-retryhelper-jetty92-0.5.2.jar
91
+ - classpath/embulk-base-restclient-0.5.3.jar
92
+ - classpath/embulk-output-mailchimp-0.3.13.jar
93
+ - classpath/embulk-util-retryhelper-jetty92-0.5.3.jar
94
94
  - classpath/jetty-client-9.2.14.v20151106.jar
95
95
  - classpath/jetty-http-9.2.14.v20151106.jar
96
96
  - classpath/jetty-io-9.2.14.v20151106.jar