This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Debug with mocha", | |
"type": "node", | |
"request": "launch", | |
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", | |
"stopOnEntry": false, | |
"args": ["--no-timeouts", "${relativeFile}"], | |
"cwd": "${workspaceRoot}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Debug with mocha", | |
"type": "node", | |
"request": "launch", | |
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", | |
"stopOnEntry": false, | |
"args": ["--no-timeouts", "--opts", "${workspaceRoot}/test/mocha-debug.opts", "${relativeFile}"], | |
"cwd": "${workspaceRoot}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add/rename alias | |
if(currentIndex > -1) | |
{ | |
renameAlias(aliasName, buildIndexName(aliasName, currentIndex), indexName); | |
} | |
else | |
{ | |
elasticClient.admin().indices().prepareAliases().addAlias(indexName, aliasName).execute(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void releaseLock(String aliasName) | |
{ | |
synchronized (aliasName) | |
{ | |
DeleteRequest deleteRequest = new DeleteRequest().index(LOCK_DIRECTORY).type(LOCK_TYPE).id(aliasName); | |
elasticClient.delete(deleteRequest); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Do the indexing | |
T res = job.rebuildIndex(indexName); | |
.... | |
public interface IndexRebuildJob<T> | |
{ | |
public T rebuildIndex(String indexName); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String mapping = getMapFile(aliasName); | |
if(mapping != null) | |
{ | |
elasticClient.admin().indices().putMapping(new PutMappingRequest(indexName).source(getMapFile(aliasName))); | |
} | |
... | |
private String getMapFile(String aliasName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create the index | |
Settings.Builder settingsBuilder = Settings.builder(); | |
for(Map.Entry<String, Integer> setting : config.getIndexSettings().entrySet()) | |
{ | |
settingsBuilder.put(setting.getKey(), setting.getValue()); | |
} | |
elasticClient.admin().indices().create(new CreateIndexRequest(indexName, settingsBuilder.build())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Delete it, if it already exists | |
if(elasticClient.admin().indices().exists(new IndicesExistsRequest(indexName)).actionGet().isExists()) | |
{ | |
elasticClient.admin().indices().delete(new DeleteIndexRequest(indexName)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int findCurrentIndex(String aliasName, int indexCount) | |
{ | |
Map<String, AliasOrIndex> allAliases = elasticClient | |
.admin() | |
.cluster() | |
.state(Requests.clusterStateRequest()) | |
.actionGet() | |
.getState() | |
.getMetaData() | |
.getAliasAndIndexLookup(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean getLock(String aliasName) | |
{ | |
synchronized (aliasName) | |
{ | |
IndexRequestBuilder indexRequest = elasticClient.prepareIndex(LOCK_DIRECTORY, LOCK_TYPE, aliasName).setSource("{}").setOpType(OpType.CREATE); | |
boolean successful = false; | |
try | |
{ | |
IndexResponse response = indexRequest.get(); |
NewerOlder