Skip to content

Commit ac08ffe

Browse files
committed
1.0.0.1
1 parent cbf7cbb commit ac08ffe

File tree

6 files changed

+61
-21
lines changed

6 files changed

+61
-21
lines changed

README.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ Installation
2121
============= ================= ================= ===========================================================
2222
ES version Plugin Release date Command
2323
------------- ----------------- ----------------- -----------------------------------------------------------
24-
0.19.11 0.19.11.2 Feb 4, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1jbhMfb
25-
0.19.11 0.19.11.2 (+S3) Feb 4, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1fEbPUD
26-
0.20.6 0.20.6.1 Feb 4, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1fX0oFU
27-
0.20.6 0.20.6.1 (+S3) Feb 4, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1e0qzIB
28-
0.90.11 0.90.11.1 Feb 4, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1frmNKM
29-
0.90.11 0.90.11.1 (+S3) Feb 4, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1doLNjm
30-
1.0.0.RC2 1.0.0.RC2.2 Feb 4, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1bmSlzk
31-
1.0.0.RC2 1.0.0.RC2.2 (+S3) Feb 4, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1bZtEZK
24+
0.19.8 0.19.8.1 Feb 15, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1f1hk1c
25+
0.19.8 0.19.8.1 (+S3) Feb 15, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1dxiqQJ
26+
0.19.11 0.19.11.3 Feb 15, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1gmHPwY
27+
0.19.11 0.19.11.3 (+S3) Feb 15, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1lTRgFF
28+
0.20.6 0.20.6.2 Feb 16, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1gPILs5
29+
0.20.6 0.20.6.2 (+S3) Feb 16, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1mlvRJh
30+
0.90.11 0.90.11.2 Feb 16, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1mlzYoB
31+
0.90.11 0.90.11.2 (+S3) Feb 16, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1j1yuuS
32+
1.0.0 1.0.0.1 Feb 16, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1bBRaBO
33+
1.0.0 1.0.0.1 (+S3) Feb 16, 2014 ./bin/plugin -install knapsack -url http://bit.ly/1cMFCX3
3234
============= ================= ================= ===========================================================
3335

3436
The S3 version includes Amazon AWS API support, it can optionally transfer archives to S3.

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>org.xbib.elasticsearch.plugin</groupId>
99
<artifactId>elasticsearch-knapsack</artifactId>
10-
<version>1.0.0.RC2.2</version>
10+
<version>1.0.0.1</version>
1111

1212
<packaging>jar</packaging>
1313

@@ -58,7 +58,7 @@
5858
<properties>
5959
<github.global.server>github</github.global.server>
6060
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
61-
<elasticsearch.version>1.0.0.RC2</elasticsearch.version>
61+
<elasticsearch.version>1.0.0</elasticsearch.version>
6262
</properties>
6363

6464
<dependencies>
@@ -74,7 +74,7 @@
7474
<dependency>
7575
<groupId>org.xbib.elasticsearch.plugin</groupId>
7676
<artifactId>elasticsearch-support</artifactId>
77-
<version>1.0.0.RC2.1</version>
77+
<version>1.0.0.2</version>
7878
<type>jar</type>
7979
<scope>compile</scope>
8080
</dependency>

src/main/java/org/xbib/elasticsearch/action/RestImportAction.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.elasticsearch.common.bytes.BytesArray;
1212
import org.elasticsearch.common.inject.Inject;
1313
import org.elasticsearch.common.io.Streams;
14+
import org.elasticsearch.common.settings.ImmutableSettings;
1415
import org.elasticsearch.common.settings.Settings;
1516
import org.elasticsearch.common.unit.TimeValue;
1617
import org.elasticsearch.common.util.concurrent.EsExecutors;
@@ -157,6 +158,8 @@ private class ImportThread extends Thread {
157158

158159
private final Map<String, CreateIndexRequest> indexRequestMap = newHashMap();
159160

161+
private final Map<String, String> indexReplicaMap = newHashMap();
162+
160163
private final Connection<Session<Packet<String>>> connection;
161164

162165
private final Session<Packet<String>> session;
@@ -253,7 +256,16 @@ public void run() {
253256
createIndexRequest = createIndexRequest(index);
254257
indexRequestMap.put(index, createIndexRequest);
255258
}
256-
createIndexRequest.settings(settingsStr);
259+
ImmutableSettings.Builder indexSettingsBuilder = ImmutableSettings.settingsBuilder()
260+
.loadFromSource(settingsStr);
261+
indexReplicaMap.put(index, indexSettingsBuilder.get("index.number_of_replicas"));
262+
// get settings, but overwrite replica, and disable refresh for faster bulk
263+
Settings indexSettings = indexSettingsBuilder
264+
.put("index.refresh_interval", -1)
265+
.put("index.number_of_replicas", 0)
266+
.build();
267+
logger.info("index {}: effective settings {}", index, indexSettings.getAsMap());
268+
createIndexRequest.settings(indexSettings);
257269
}
258270
}
259271
else if ("_mapping".equals(id)) {
@@ -294,7 +306,19 @@ else if ("_mapping".equals(id)) {
294306
}
295307
logger.info("end of import: {}", status);
296308
session.close();
297-
bulkClient.refresh().shutdown();
309+
for (String index : indexReplicaMap.keySet()) {
310+
try {
311+
bulkClient.setIndex(index);
312+
logger.info("setting refresh rate for index {}", index);
313+
bulkClient.update("index.refresh_interval", 1);
314+
Integer replica = Integer.parseInt(indexReplicaMap.get(index));
315+
logger.info("setting replica level {} for index {}", replica, index);
316+
bulkClient.update("index.number_of_replicas", replica);
317+
} catch (Exception e) {
318+
logger.error(e.getMessage(), e);
319+
}
320+
}
321+
bulkClient.shutdown();
298322
bulkClient = null;
299323
} catch (Throwable e) {
300324
logger.error(e.getMessage(), e);

src/main/java/org/xbib/elasticsearch/plugin/knapsack/Build.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11

22
package org.xbib.elasticsearch.plugin.knapsack;
33

4-
import org.xbib.elasticsearch.plugin.support.SupportPlugin;
5-
64
import java.io.ByteArrayOutputStream;
7-
import java.io.IOException;
85
import java.io.InputStream;
9-
import java.io.OutputStream;
106
import java.io.StringReader;
117
import java.net.URL;
128
import java.util.Enumeration;
@@ -24,8 +20,8 @@ public class Build {
2420
String date = "NA";
2521

2622
try {
27-
String pluginName = SupportPlugin.class.getName();
28-
Enumeration<URL> e = SupportPlugin.class.getClassLoader().getResources("/es-plugin.properties");
23+
String pluginName = KnapsackPlugin.class.getName();
24+
Enumeration<URL> e = KnapsackPlugin.class.getClassLoader().getResources("es-plugin.properties");
2925
while (e.hasMoreElements()) {
3026
URL url = e.nextElement();
3127
InputStream in = url.openStream();

src/main/java/org/xbib/elasticsearch/plugin/knapsack/KnapsackPacket.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.xbib.io.URIUtil;
66

77
import java.io.File;
8+
import java.util.StringTokenizer;
89

910
public class KnapsackPacket implements Packet<String> {
1011

@@ -56,10 +57,25 @@ public static String encodeName(String[] components) {
5657
}
5758

5859
public static String[] decodeName(String component) {
59-
String[] components = component.split(File.separator);
60+
String[] components = split(component, File.separator);
6061
for (int i = 0; i < components.length; i++) {
6162
components[i] = URIUtil.decode(components[i] != null ? components[i] : "", URIUtil.UTF8);
6263
}
6364
return components;
6465
}
66+
67+
/**
68+
* Split "str" into tokens by delimiters and optionally remove white spaces
69+
* from the splitted tokens.
70+
*/
71+
private static String[] split(String str, String delims) {
72+
StringTokenizer tokenizer = new StringTokenizer(str, delims);
73+
int n = tokenizer.countTokens();
74+
String[] list = new String[n];
75+
for (int i = 0; i < n; i++) {
76+
list[i] = tokenizer.nextToken();
77+
}
78+
return list;
79+
}
80+
6581
}

src/main/java/org/xbib/elasticsearch/plugin/knapsack/KnapsackPlugin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ public class KnapsackPlugin extends AbstractPlugin {
1111

1212
@Override
1313
public String name() {
14-
return "knapsack-" + Build.getInstance().getVersion();
14+
return "knapsack-" +
15+
Build.getInstance().getVersion() + "-" +
16+
Build.getInstance().getShortHash();
1517
}
1618

1719
@Override

0 commit comments

Comments
 (0)