本文整理了Java中org.elasticsearch.hadoop.util.Assert
类的一些代码示例,展示了Assert
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert
类的具体详情如下:
包路径:org.elasticsearch.hadoop.util.Assert
类名称:Assert
[英]Assertion utility used for validating arguments.
[中]用于验证参数的断言实用程序。
代码示例来源:origin: elastic/elasticsearch-hadoop
public static void isTrue(Boolean object) {
isTrue(object, "[Assertion failed] - this argument must be true");
}
代码示例来源:origin: elastic/elasticsearch-hadoop
private ContentBuilder(Generator generator, ValueWriter writer) {
Assert.notNull(generator);
this.generator = generator;
this.writer = writer;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public SearchRequestBuilder shard(String shard) {
Assert.hasText(shard, "Invalid shard");
this.shard = shard;
return this;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public static Field findField(Class<?> clazz, String name, Class<?> type) {
Assert.notNull(clazz, "Class must not be null");
Assert.isTrue(name != null || type != null, "Either name or type of the field must be specified");
Class<?> searchType = clazz;
while (!Object.class.equals(searchType) && searchType != null) {
Field[] fields = searchType.getDeclaredFields();
for (Field field : fields) {
if ((name == null || name.equals(field.getName())) && (type == null || type.equals(field.getType()))) {
return field;
}
}
searchType = searchType.getSuperclass();
}
return null;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
Assert.hasText(resource, errorMessage + resource);
type = res.substring(slash + 1);
typed = true;
Assert.hasText(type, "No type found; expecting [index]/[type]");
} else {
index = res;
typed = false;
Assert.hasText(index, "No index found; expecting [index]/[type]");
Assert.isTrue(!StringUtils.hasWhitespace(index) && !StringUtils.hasWhitespace(type), "Index/type should not contain whitespaces");
Assert.isTrue(!StringUtils.hasWhitespace(ingestPipeline), "Ingest Pipeline name should not contain whitespaces");
Assert.isTrue(!(ES_OPERATION_UPDATE.equals(settings.getOperation()) || ES_OPERATION_UPSERT.equals(settings.getOperation())), "Cannot specify an ingest pipeline when doing updates or upserts");
bulkEndpoint = bulkEndpoint + "?pipeline=" + ingestPipeline;
代码示例来源:origin: elastic/elasticsearch-hadoop
public static void hasNoText(CharSequence sequence) {
hasNoText(sequence, "[Assertion failed] - this CharSequence argument must be empty");
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public SearchRequestBuilder fields(String fieldsCSV) {
Assert.isFalse(this.excludeSource, "Fields can't be requested because _source section is excluded");
this.fields = fieldsCSV;
return this;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
/**
* Writes the objects to index.
*
* @param ba The data as a bytes array
*/
public void writeProcessedToIndex(BytesArray ba) {
Assert.notNull(ba, "no data given");
Assert.isTrue(ba.length() > 0, "no data given");
lazyInitWriting();
trivialBytesRef.reset();
trivialBytesRef.add(ba);
doWriteToIndex(trivialBytesRef);
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public SearchRequestBuilder excludeSource(boolean value) {
if (value) {
Assert.hasNoText(this.fields, String.format("_source section can't be excluded if fields [%s] are requested", this.fields));
}
this.excludeSource = value;
return this;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public static void isFalse(Boolean object) {
isFalse(object, "[Assertion failed] - this argument must be false");
}
}
代码示例来源:origin: elastic/elasticsearch-hadoop
/**
* Creates a new byte array output stream, with a buffer capacity of
* the specified size, in bytes.
*
* @param size the initial size.
* @throws EsHadoopIllegalArgumentException if size is negative.
*/
public FastByteArrayOutputStream(int size) {
Assert.isTrue(size >= 0, "Negative initial size: " + size);
data = new BytesArray(size);
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public SparkSettings(SparkConf cfg) {
Assert.notNull(cfg, "non-null spark configuration expected");
this.cfg = cfg;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public MessageTemplate(ElasticCommonSchema schema, Map<String, String> labels, Set<String> tags, HostData host,
String eventCategory, String eventType) {
Assert.hasText(eventCategory, "Missing " + FieldNames.FIELD_EVENT_CATEGORY + " value for ECS template.");
Assert.hasText(eventType, "Missing " + FieldNames.FIELD_EVENT_TYPE + " value for ECS template.");
this.schema = schema;
this.labels = labels;
this.tags = tags;
this.host = host;
this.eventCategory = eventCategory;
this.eventType = eventType;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
HeartBeat(final Progressable progressable, Configuration cfg, TimeValue lead, final Log log) {
Assert.notNull(progressable, "a valid progressable is required to report status to Hadoop");
TimeValue tv = HadoopCfgUtils.getTaskTimeout(cfg);
Assert.isTrue(tv.getSeconds() <= 0 || tv.getSeconds() > lead.getSeconds(), "Hadoop timeout is shorter than the heartbeat");
this.progressable = progressable;
long cfgMillis = (tv.getMillis() > 0 ? tv.getMillis() : 0);
// the task is simple hence the delay = timeout - lead, that is when to start the notification right before the timeout
this.delay = new TimeValue(Math.abs(cfgMillis - lead.getMillis()), TimeUnit.MILLISECONDS);
this.log = log;
String taskId;
TaskID taskID = HadoopCfgUtils.getTaskID(cfg);
if (taskID == null) {
log.warn("Cannot determine task id...");
taskId = "<unknown>";
if (log.isTraceEnabled()) {
log.trace("Current configuration is " + HadoopCfgUtils.asProperties(cfg));
}
}
else {
taskId = "" + taskID;
}
id = taskId;
}
代码示例来源:origin: org.elasticsearch/elasticsearch-hadoop
public static void hasNoText(CharSequence sequence) {
hasNoText(sequence, "[Assertion failed] - this CharSequence argument must be empty");
}
代码示例来源:origin: org.elasticsearch/elasticsearch-hadoop-mr
public SearchRequestBuilder fields(String fieldsCSV) {
Assert.isFalse(this.excludeSource, "Fields can't be requested because _source section is excluded");
this.fields = fieldsCSV;
return this;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public SearchRequestBuilder scroll(long keepAliveMillis) {
Assert.isTrue(keepAliveMillis > 0, "Invalid scroll");
this.scroll = TimeValue.timeValueMillis(keepAliveMillis);
return this;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public HadoopSettings(Configuration cfg) {
Assert.notNull(cfg, "Non-null properties expected");
this.cfg = cfg;
}
代码示例来源:origin: elastic/elasticsearch-hadoop
public static void hasText(CharSequence sequence) {
hasText(sequence, "[Assertion failed] - this CharSequence argument must have text; it must not be null, empty, or blank");
}
代码示例来源:origin: org.elasticsearch/elasticsearch-hadoop-mr
public static void hasNoText(CharSequence sequence) {
hasNoText(sequence, "[Assertion failed] - this CharSequence argument must be empty");
}
内容来源于网络,如有侵权,请联系作者删除!