本文整理汇总了Java中org.elasticsearch.river.RiverName类的典型用法代码示例。如果您正苦于以下问题:Java RiverName类的具体用法?Java RiverName怎么用?Java RiverName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RiverName类属于org.elasticsearch.river包,在下文中一共展示了RiverName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BigQueryRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@Inject
public BigQueryRiver(final RiverName riverName, final RiverSettings settings, final Client esClient) {
super(riverName, settings);
this.esClient = esClient;
logger.info("Creating BigQuery Stream River");
indexScript = readConfig("index", riverName.name());
typeScript = readConfig("type", "import");
project = readConfig("project");
keyFile = readConfig("keyFile");
account = readConfig("account");
query = readConfig("query");
mappingScript = readConfig("mapping", null);
create = Boolean.valueOf(readConfig("create", null));
uniqueIdField = readConfig("uniqueIdField", null);
interval = Long.parseLong(readConfig("interval", "600000"));
}
示例2: masterOperation
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@Override
protected void masterOperation(GetRiverStateRequest request, ClusterState state, ActionListener<GetRiverStateResponse> listener) throws ElasticsearchException {
MetaData metaData = state.metaData();
RiverStatesMetaData riverStates = metaData.custom(RiverStatesMetaData.TYPE);
if (request.getRiverName() == null || request.getRiverType() == null) {
listener.onResponse(new GetRiverStateResponse(request, riverStates.rivers()));
} else {
String riverName = request.getRiverName();
String riverType = request.getRiverType();
ImmutableList.Builder<RiverState> builder = ImmutableList.builder();
for (Map.Entry<RiverName, River> entry : RiverHelper.rivers(injector).entrySet()) {
RiverName name = entry.getKey();
if (("*".equals(riverName) || name.getName().equals(riverName)) && ("*".equals(riverType) || name.getType().equals(riverType)) && entry.getValue() instanceof StatefulRiver) {
StatefulRiver river = (StatefulRiver) entry.getValue();
if (river.getRiverState() != null) {
builder.add(river.getRiverState());
}
}
}
listener.onResponse(new GetRiverStateResponse(request, builder.build()));
}
}
示例3: nodeOperation
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@Override
protected NodeRiverExecuteResponse nodeOperation(NodeRiverExecuteRequest request) throws ElasticsearchException {
NodeInfo nodeInfo = nodeService.info(false, true, false, true, false, false, true, false, true);
String riverType = request.getRiverType();
String riverName = request.getRiverName();
for (Map.Entry<RiverName, River> entry : RiverHelper.rivers(injector).entrySet()) {
RiverName name = entry.getKey();
if ((riverName == null || name.getName().equals(riverName))
&& (riverType == null || name.getType().equals(riverType))
&& entry.getValue() instanceof RunnableRiver) {
RunnableRiver river = (RunnableRiver) entry.getValue();
river.run();
return new NodeRiverExecuteResponse(nodeInfo.getNode()).setExecuted(true);
}
}
return new NodeRiverExecuteResponse(nodeInfo.getNode()).setExecuted(false);
}
示例4: delete
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
public static void delete(final Client client, final RiverName riverName) {
DeleteMappingResponse deleteMappingResponse;
try {
deleteMappingResponse = client.admin().indices()
.prepareDeleteMapping("_river").setType(riverName.name())
.execute().actionGet();
} catch (final ElasticsearchException e) {
throw new EsUtilSystemException("Failed to delete "
+ riverName.name(), e);
}
if (!deleteMappingResponse.isAcknowledged()) {
throw new EsUtilSystemException("Failed to delete "
+ riverName.name() + ". "
+ deleteMappingResponse.toString());
}
}
示例5: GitRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@Inject
protected GitRiver(RiverName riverName, RiverSettings settings, @RiverIndexName String riverIndexName, Client client) throws InvocationTargetException, IllegalAccessException {
super(riverName, settings);
this.client = client;
logger.info("Creating Git river");
if (settings.settings().containsKey("git")) {
Map<String, Object> gitSettings = (Map<String, Object>) settings.settings().get("git");
BeanUtilsBean2.getInstance().populate(context, transformKeys(gitSettings, new Function<String, String>() {
@Override
public String apply(String input) {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input);
}
}));
}
context.setRiverName(riverName.name());
context.setRiverIndexName(riverIndexName);
context.setClient(client);
context.setIssuePattern(compilePattern(context.getIssueRegex()));
}
示例6: ArangoDbRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@Inject
public ArangoDbRiver( //
final RiverName riverName, //
final RiverSettings settings, //
final Client client, //
final ScriptService scriptService, //
final ArangoDbConfig config, //
final WalReaderRunnable walReaderRunnable, //
final IndexWriterRunnable indexWriterRunnable, //
@Named("arangodb_river_walReaderRunnable_threadfactory") final ThreadFactory walReaderThreadFactory, //
@Named("arangodb_river_indexWriterRunnable_threadfactory") final ThreadFactory indexWriterThreadFactory //
) throws ArangoDbException {
super(riverName, settings);
this.client = client;
this.config = config;
this.walReaderRunnable = walReaderRunnable;
this.indexWriterRunnable = indexWriterRunnable;
this.walReaderThreadFactory = walReaderThreadFactory;
this.indexWriterThreadFactory = indexWriterThreadFactory;
logger.debug("Prefix: [{}] - name: [{}]", logger.getPrefix(), logger.getName());
logger.debug("River settings: [{}]", settings.settings());
}
示例7: WildlfyRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Inject
public WildlfyRiver(RiverName riverName, RiverSettings settings, Client client, ThreadPool threadPool) {
super(riverName, settings);
this.client = client;
this.threadPool = threadPool;
logger.info("Creating wildfly metric stream");
indexName = riverName.name();
typeName = "metrics";
//dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
timeFormatter = ISODateTimeFormat.dateTimeNoMillis();
}
示例8: prepareRiverInstanceForTest
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
/**
* Prepare {@link RemoteRiver} instance for unit test, with Mockito moceked jiraClient and elasticSearchClient.
*
* @param urlGetDocuments parameter for remote settings
* @param remoteSettingsAdd additional/optional config properties to be added into <code>remote</code> configuration
* node
* @param toplevelSettingsAdd additional/optional config properties to be added into toplevel node. Do not add
* <code>remote</code> here, will be ignored.
* @param initRemoteClientMock if set to true then Mockito mock instance is created and set into
* {@link RemoteRiver#remoteSystemClient}
* @return instance for tests
* @throws Exception from constructor
*/
public static RemoteRiver prepareRiverInstanceForTest(String urlGetDocuments, Map<String, Object> remoteSettingsAdd,
Map<String, Object> toplevelSettingsAdd, boolean initRemoteClientMock) throws Exception {
Map<String, Object> settings = new HashMap<String, Object>();
if (toplevelSettingsAdd != null)
settings.putAll(toplevelSettingsAdd);
if (urlGetDocuments != null || remoteSettingsAdd != null) {
Map<String, Object> remoteSettings = new HashMap<String, Object>();
settings.put("remote", remoteSettings);
if (remoteSettingsAdd != null)
remoteSettings.putAll(remoteSettingsAdd);
remoteSettings.put(GetJSONClient.CFG_URL_GET_DOCUMENTS, urlGetDocuments);
remoteSettings.put(GetJSONClient.CFG_URL_GET_SPACES, urlGetDocuments);
}
Settings gs = mock(Settings.class);
RiverSettings rs = new RiverSettings(gs, settings);
Client clientMock = mock(Client.class);
RemoteRiver tested = new RemoteRiver(new RiverName("remote", RIVER_NAME), rs, clientMock);
if (initRemoteClientMock) {
IRemoteSystemClient remoteClientMock = mock(IRemoteSystemClient.class);
tested.remoteSystemClient = remoteClientMock;
}
return tested;
}
示例9: ZookeeperRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@Inject
public ZookeeperRiver(final RiverName riverName, final RiverSettings settings,
final Client client) {
super(riverName, settings);
this.client = client;
logger.info("CREATE ZookeeperRiver");
// TODO Your code..
}
示例10: GitHubRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Inject
public GitHubRiver(RiverName riverName, RiverSettings settings, Client client) {
super(riverName, settings);
this.client = client;
if (!settings.settings().containsKey("github")) {
throw new IllegalArgumentException("Need river settings - owner and repository.");
}
// get settings
Map<String, Object> githubSettings = (Map<String, Object>) settings.settings().get("github");
owner = XContentMapValues.nodeStringValue(githubSettings.get("owner"), null);
repository = XContentMapValues.nodeStringValue(githubSettings.get("repository"), null);
index = String.format("%s&%s", owner, repository);
userRequestedInterval = XContentMapValues.nodeIntegerValue(githubSettings.get("interval"), 60);
// auth (optional)
username = null;
password = null;
if (githubSettings.containsKey("authentication")) {
Map<String, Object> auth = (Map<String, Object>) githubSettings.get("authentication");
username = XContentMapValues.nodeStringValue(auth.get("username"), null);
password = XContentMapValues.nodeStringValue(auth.get("password"), null);
}
// endpoint (optional - default to github.com)
endpoint = XContentMapValues.nodeStringValue(githubSettings.get("endpoint"), "https://api.github.com");
logger.info("Created GitHub river.");
}
示例11: JDBCRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@Inject
@SuppressWarnings({"unchecked"})
public JDBCRiver(RiverName riverName, RiverSettings riverSettings, Client client) {
super(riverName, riverSettings);
if (!riverSettings.settings().containsKey("jdbc")) {
throw new IllegalArgumentException("no 'jdbc' settings in river settings?");
}
this.client = client;
this.feeder = createFeeder(riverName.getType(), riverName.getName(), riverSettings);
}
示例12: rivers
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
/**
* Retrieve the registered rivers using reflection. This hack can be removed when RiversService gets a public API.
*
* @param injector injector
* @return map of rivers or null if not possible
*/
@SuppressWarnings({"unchecked"})
public static ImmutableMap<RiverName, River> rivers(Injector injector) {
RiversService riversService = injector.getInstance(RiversService.class);
try {
Field field = RiversService.class.getDeclaredField("rivers");
if (field != null) {
field.setAccessible(true);
return (ImmutableMap<RiverName, River>) field.get(riversService);
}
} catch (Throwable e) {
//
}
return ImmutableMap.of();
}
示例13: setupContext
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
private void setupContext(RiverSource riverSource, String riverResource) throws IOException {
RiverSettings riverSettings = riverSettings(riverResource);
context.setRiverName(new RiverName(index, type).getName());
context.setRiverMouth(new MockRiverMouth());
context.setRiverSource(riverSource);
context.setRiverSettings(riverSettings.settings());
context.columnEscape(true);
}
示例14: KafkaRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
@Inject
public KafkaRiver(RiverName riverName, RiverSettings settings, Client client) {
super(riverName, settings);
this.client = client;
try {
logger.info("KafkaRiver created: name={}, type={}", riverName.getName(), riverName.getType());
this.riverConfig = new KafkaRiverConfig(settings);
} catch (Exception e) {
logger.error("Unexpected Error occurred", e);
throw new RuntimeException(e);
}
}
示例15: HBaseRiver
import org.elasticsearch.river.RiverName; //导入依赖的package包/类
/**
* Loads and verifies all the configuration needed to run this river.
*
* @param riverName
* @param settings
* @param esClient
*/
@Inject
public HBaseRiver(final RiverName riverName, final RiverSettings settings, final Client esClient) {
super(riverName, settings);
this.esClient = esClient;
this.logger.info("Creating HBase Stream River");
this.normalizeFields = Boolean.parseBoolean(readConfig("normalizeFields", "true"));
this.hosts = readConfig("hosts");
this.table = readConfig("table");
this.columnSeparator = readConfig("columnSeparator", null);
this.idField = normalizeField(readConfig("idField", null));
this.index = normalizeField(readConfig("index", riverName.name()));
this.type = normalizeField(readConfig("type", this.table));
this.interval = Long.parseLong(readConfig("interval", "600000"));
this.batchSize = Integer.parseInt(readConfig("batchSize", "100"));
this.charset = Charset.forName(readConfig("charset", "UTF-8"));
this.deleteOld = Boolean.parseBoolean(readConfig("deleteOld", "false"));
final String family = readConfig("family", null);
this.family = family != null ? family.getBytes(this.charset) : null;
this.qualifiers = readConfig("qualifiers", null);
this.customMapping = readConfig("customMapping", null);
if (this.interval <= 0) {
throw new IllegalArgumentException("The interval between runs must be at least 1 ms. The current config is set to "
+ this.interval);
}
if (this.batchSize <= 0) {
throw new IllegalArgumentException("The batch size must be set to at least 1. The current config is set to " + this.batchSize);
}
}