use of org.pentaho.di.trans.steps.elasticsearchbulk.ElasticSearchBulkMeta.Server in project pentaho-kettle by pentaho.
the class ElasticSearchBulkDialog method test.
private void test(TestType testType) {
try {
ElasticSearchBulkMeta tempMeta = new ElasticSearchBulkMeta();
toModel(tempMeta);
// if ( !tempMeta.getServers().isEmpty() ) {
Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(Settings.Builder.EMPTY_SETTINGS);
tempMeta.getSettingsMap().entrySet().stream().forEach((s) -> settingsBuilder.put(s.getKey(), transMeta.environmentSubstitute(s.getValue())));
try (PreBuiltTransportClient client = new PreBuiltTransportClient(settingsBuilder.build())) {
for (Server server : tempMeta.getServers()) {
client.addTransportAddress(new TransportAddress(InetAddress.getByName(transMeta.environmentSubstitute(server.getAddress())), server.getPort()));
}
AdminClient admin = client.admin();
switch(testType) {
case INDEX:
if (StringUtils.isBlank(tempMeta.getIndex())) {
showError(BaseMessages.getString(PKG, "ElasticSearchBulk.Error.NoIndex"));
break;
}
// First check to see if the index exists
IndicesExistsRequestBuilder indicesExistBld = admin.indices().prepareExists(tempMeta.getIndex());
IndicesExistsResponse indicesExistResponse = indicesExistBld.execute().get();
if (!indicesExistResponse.isExists()) {
showError(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.Error.NoIndex"));
return;
}
RecoveryRequestBuilder indicesBld = admin.indices().prepareRecoveries(tempMeta.getIndex());
ActionFuture<RecoveryResponse> lafInd = indicesBld.execute();
String shards = "" + lafInd.get().getSuccessfulShards() + "/" + lafInd.get().getTotalShards();
showMessage(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.TestIndex.TestOK", shards));
break;
case CLUSTER:
ClusterStateRequestBuilder clusterBld = admin.cluster().prepareState();
ActionFuture<ClusterStateResponse> lafClu = clusterBld.execute();
ClusterStateResponse cluResp = lafClu.actionGet();
String name = cluResp.getClusterName().value();
ClusterState cluState = cluResp.getState();
int numNodes = cluState.getNodes().getSize();
showMessage(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.TestCluster.TestOK", name, numNodes));
break;
default:
break;
}
}
} catch (NoNodeAvailableException | MasterNotDiscoveredException e) {
showError(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.Error.NoNodesFound"));
} catch (Exception e) {
showError(e.getLocalizedMessage());
}
}
use of org.pentaho.di.trans.steps.elasticsearchbulk.ElasticSearchBulkMeta.Server in project pentaho-kettle by pentaho.
the class ElasticSearchBulk method initClient.
private void initClient() throws UnknownHostException {
Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(Settings.Builder.EMPTY_SETTINGS);
meta.getSettingsMap().entrySet().stream().forEach((s) -> settingsBuilder.put(s.getKey(), environmentSubstitute(s.getValue())));
PreBuiltTransportClient tClient = new PreBuiltTransportClient(settingsBuilder.build());
for (Server server : meta.getServers()) {
tClient.addTransportAddress(new TransportAddress(InetAddress.getByName(environmentSubstitute(server.getAddress())), server.getPort()));
}
client = tClient;
/**
* With the upgrade to elasticsearch 6.3.0, removed the NodeBuilder,
* which was removed from the elasticsearch 5.0 API, see:
* https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking_50_java_api_changes
* .html#_nodebuilder_removed
*/
}
use of org.pentaho.di.trans.steps.elasticsearchbulk.ElasticSearchBulkMeta.Server in project pentaho-kettle by pentaho.
the class ElasticSearchBulkDialog method getData.
/**
* Read the data from the ElasticSearchBulkMeta object and show it in this dialog.
*
* @param in The ElasticSearchBulkMeta object to obtain the data from.
*/
public void getData(ElasticSearchBulkMeta in) {
wIndex.setText(Const.NVL(in.getIndex(), ""));
wType.setText(Const.NVL(in.getType(), ""));
wBatchSize.setText(Const.NVL(in.getBatchSize(), "" + ElasticSearchBulkMeta.DEFAULT_BATCH_SIZE));
wStopOnError.setSelection(in.isStopOnError());
wTimeOut.setText(Const.NVL(in.getTimeOut(), ""));
wTimeOut.setTimeUnit(in.getTimeoutUnit());
wIdInField.setText(Const.NVL(in.getIdInField(), ""));
wIsOverwrite.setSelection(in.isOverWriteIfSameId());
wIsJson.setSelection(in.isJsonInsert());
wJsonField.setText(Const.NVL(in.getJsonField(), ""));
// listener not working here
wJsonField.setEnabled(wIsJson.getSelection());
wUseOutput.setSelection(in.isUseOutput());
wIdOutField.setText(Const.NVL(in.getIdOutField(), ""));
// listener not working here
wIdOutField.setEnabled(wUseOutput.getSelection());
// Fields
mapToTableView(model.getFieldsMap(), wFields);
// Servers
for (ElasticSearchBulkMeta.Server server : model.getServers()) {
wServers.add(server.address, "" + server.port);
}
wServers.removeEmptyRows();
wServers.setRowNums();
// Settings
mapToTableView(model.getSettingsMap(), wSettings);
wStepname.selectAll();
wStepname.setFocus();
}
Aggregations