本文整理汇总了Java中org.elasticsearch.common.logging.ESLogger类的典型用法代码示例。如果您正苦于以下问题:Java ESLogger类的具体用法?Java ESLogger怎么用?Java ESLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ESLogger类属于org.elasticsearch.common.logging包,在下文中一共展示了ESLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: respForbidden
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
public static void respForbidden(final HttpRequest request, final HttpChannel channel, ESLogger logger) {
XContentBuilder builder;
try {
builder = ContentBuilder.restContentBuilder(request);
builder.startObject()
.field(new XContentBuilderString("status"), RestStatus.FORBIDDEN)
.field(new XContentBuilderString("message"),
"You are not login")
.endObject();
channel.sendResponse(
new BytesRestResponse(RestStatus.FORBIDDEN, builder));
} catch (IOException e) {
if (logger != null) {
logger.error("Get Exception in checkPermission: " + e.getMessage());
}
e.printStackTrace();
}
}
示例2: respIpForbidden
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
public static void respIpForbidden(final HttpRequest request, final HttpChannel channel, ESLogger logger) {
XContentBuilder builder;
try {
builder = ContentBuilder.restContentBuilder(request);
builder.startObject()
.field(new XContentBuilderString("status"), RestStatus.FORBIDDEN)
.field(new XContentBuilderString("message"),
"Your ip is not in auth list")
.endObject();
channel.sendResponse(
new BytesRestResponse(RestStatus.FORBIDDEN, builder));
} catch (IOException e) {
if (logger != null) {
logger.error("Get Exception in checkIpPermission: " + e.getMessage());
}
e.printStackTrace();
}
}
示例3: PageDownstreamContext
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
public PageDownstreamContext(ESLogger logger,
String nodeName,
int id,
String name,
PageDownstream pageDownstream,
Streamer<?>[] streamer,
RamAccountingContext ramAccountingContext,
int numBuckets,
@Nullable FlatProjectorChain projectorChain) {
super(id, logger);
this.nodeName = nodeName;
this.name = name;
this.pageDownstream = pageDownstream;
this.streamer = streamer;
this.ramAccountingContext = ramAccountingContext;
this.numBuckets = numBuckets;
this.projectorChain = projectorChain;
bucketFutures = new ArrayList<>(numBuckets);
allFuturesSet = new BitSet(numBuckets);
exhausted = new BitSet(numBuckets);
initBucketFutures();
}
示例4: ScriptParameterParser
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
public ScriptParameterParser(Set<String> parameterNames) {
ESLogger logger = Loggers.getLogger(getClass());
deprecationLogger = new DeprecationLogger(logger);
if (parameterNames == null || parameterNames.isEmpty()) {
inlineParameters = Collections.singleton(ScriptService.SCRIPT_INLINE);
fileParameters = Collections.singleton(ScriptService.SCRIPT_FILE);
indexedParameters = Collections.singleton(ScriptService.SCRIPT_ID);
} else {
inlineParameters = new HashSet<>();
fileParameters = new HashSet<>();
indexedParameters = new HashSet<>();
for (String parameterName : parameterNames) {
if (ParseFieldMatcher.EMPTY.match(parameterName, ScriptService.SCRIPT_LANG)) {
throw new IllegalArgumentException("lang is reserved and cannot be used as a parameter name");
}
inlineParameters.add(new ParseField(parameterName));
fileParameters.add(new ParseField(parameterName + FILE_SUFFIX));
indexedParameters.add(new ParseField(parameterName + INDEXED_SUFFIX));
}
}
}
示例5: QueryCollector
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
QueryCollector(ESLogger logger, PercolateContext context, boolean isNestedDoc) throws IOException {
this.logger = logger;
this.queries = context.percolateQueries();
this.searcher = context.docSearcher();
final MappedFieldType uidMapper = context.mapperService().smartNameFieldType(UidFieldMapper.NAME);
this.uidFieldData = context.fieldData().getForField(uidMapper);
this.isNestedDoc = isNestedDoc;
List<Aggregator> aggregatorCollectors = new ArrayList<>();
if (context.aggregations() != null) {
AggregationContext aggregationContext = new AggregationContext(context);
context.aggregations().aggregationContext(aggregationContext);
Aggregator[] aggregators = context.aggregations().factories().createTopLevelAggregators(aggregationContext);
for (int i = 0; i < aggregators.length; i++) {
if (!(aggregators[i] instanceof GlobalAggregator)) {
Aggregator aggregator = aggregators[i];
aggregatorCollectors.add(aggregator);
}
}
context.aggregations().aggregators(aggregators);
}
aggregatorCollector = BucketCollector.wrap(aggregatorCollectors);
aggregatorCollector.preCollection();
}
示例6: deleteLeftoverShardDirectory
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
/**
* This method tries to delete left-over shards where the index name has been reused but the UUID is different
* to allow the new shard to be allocated.
*/
public static void deleteLeftoverShardDirectory(ESLogger logger, NodeEnvironment env, ShardLock lock, Settings indexSettings) throws IOException {
final String indexUUID = indexSettings.get(IndexMetaData.SETTING_INDEX_UUID, IndexMetaData.INDEX_UUID_NA_VALUE);
final Path[] paths = env.availableShardPaths(lock.getShardId());
for (Path path : paths) {
ShardStateMetaData load = ShardStateMetaData.FORMAT.loadLatestState(logger, path);
if (load != null) {
if (load.indexUUID.equals(indexUUID) == false && IndexMetaData.INDEX_UUID_NA_VALUE.equals(load.indexUUID) == false) {
logger.warn("{} deleting leftover shard on path: [{}] with a different index UUID", lock.getShardId(), path);
assert Files.isDirectory(path) : path + " is not a directory";
NodeEnvironment.acquireFSLockForPaths(indexSettings, paths);
IOUtils.rm(path);
}
}
}
}
示例7: checksumFromLuceneFile
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
private static void checksumFromLuceneFile(Directory directory, String file, ImmutableMap.Builder<String, StoreFileMetaData> builder, ESLogger logger, Version version, boolean readFileAsHash) throws IOException {
final String checksum;
final BytesRefBuilder fileHash = new BytesRefBuilder();
try (final IndexInput in = directory.openInput(file, IOContext.READONCE)) {
final long length;
try {
length = in.length();
if (length < CodecUtil.footerLength()) {
// truncated files trigger IAE if we seek negative... these files are really corrupted though
throw new CorruptIndexException("Can't retrieve checksum from file: " + file + " file length must be >= " + CodecUtil.footerLength() + " but was: " + in.length(), in);
}
if (readFileAsHash) {
final VerifyingIndexInput verifyingIndexInput = new VerifyingIndexInput(in); // additional safety we checksum the entire file we read the hash for...
hashFile(fileHash, new InputStreamIndexInput(verifyingIndexInput, length), length);
checksum = digestToString(verifyingIndexInput.verify());
} else {
checksum = digestToString(CodecUtil.retrieveChecksum(in));
}
} catch (Throwable ex) {
logger.debug("Can retrieve checksum from file [{}]", ex, file);
throw ex;
}
builder.put(file, new StoreFileMetaData(file, length, checksum, version, fileHash.get()));
}
}
示例8: buildShardLevelInfo
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
static void buildShardLevelInfo(ESLogger logger, ShardStats[] stats, HashMap<String, Long> newShardSizes, HashMap<ShardRouting, String> newShardRoutingToDataPath, ClusterState state) {
MetaData meta = state.getMetaData();
for (ShardStats s : stats) {
IndexMetaData indexMeta = meta.index(s.getShardRouting().index());
Settings indexSettings = indexMeta == null ? null : indexMeta.getSettings();
newShardRoutingToDataPath.put(s.getShardRouting(), s.getDataPath());
long size = s.getStats().getStore().sizeInBytes();
String sid = ClusterInfo.shardIdentifierFromRouting(s.getShardRouting());
if (logger.isTraceEnabled()) {
logger.trace("shard: {} size: {}", sid, size);
}
if (indexSettings != null && IndexMetaData.isIndexUsingShadowReplicas(indexSettings)) {
// Shards on a shared filesystem should be considered of size 0
if (logger.isTraceEnabled()) {
logger.trace("shard: {} is using shadow replicas and will be treated as size 0", sid);
}
size = 0;
}
newShardSizes.put(sid, size);
}
}
示例9: addDefaultUnitsIfNeeded
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
/** As of 2.0 we require units for time and byte-sized settings.
* This methods adds default units to any settings that are part of timeSettings or byteSettings and don't specify a unit.
**/
@Nullable
public static Settings addDefaultUnitsIfNeeded(Set<String> timeSettings, Set<String> byteSettings, ESLogger logger, Settings settings) {
Settings.Builder newSettingsBuilder = null;
for (Map.Entry<String, String> entry : settings.getAsMap().entrySet()) {
String settingName = entry.getKey();
String settingValue = entry.getValue();
String newSettingValue = convertedValue(timeSettings, settingName, settingValue, logger, "ms", "time");
if (settingValue.equals(newSettingValue) == false) {
newSettingsBuilder = initSettingsBuilder(settings, newSettingsBuilder);
newSettingsBuilder.put(settingName, newSettingValue);
}
newSettingValue = convertedValue(byteSettings, settingName, settingValue, logger, "b", "byte-sized");
if (settingValue.equals(newSettingValue) == false) {
newSettingsBuilder = initSettingsBuilder(settings, newSettingsBuilder);
newSettingsBuilder.put(settingName, newSettingValue);
}
}
if (newSettingsBuilder == null) {
return settings;
}
return newSettingsBuilder.build();
}
示例10: convertedValue
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
private static String convertedValue(Set<String> settingsThatRequireUnits,
String settingName,
String settingValue,
ESLogger logger,
String unit,
String unitName) {
if (settingsThatRequireUnits.contains(settingName) == false) {
return settingValue;
}
try {
Long.parseLong(settingValue);
} catch (NumberFormatException e) {
return settingValue;
}
// It's a naked number that previously would be interpreted as default unit; now we add it:
logger.warn("{} setting [{}] with value [{}] is missing units; assuming default units ({}) but in future versions this will be a hard error",
unitName, settingName, settingValue, unit);
return settingValue + unit;
}
示例11: MemoryCircuitBreaker
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
/**
* Create a circuit breaker that will break if the number of estimated
* bytes grows above the limit. All estimations will be multiplied by
* the given overheadConstant. Uses the given oldBreaker to initialize
* the starting offset.
* @param limit circuit breaker limit
* @param overheadConstant constant multiplier for byte estimations
* @param oldBreaker the previous circuit breaker to inherit the used value from (starting offset)
*/
public MemoryCircuitBreaker(ByteSizeValue limit, double overheadConstant, MemoryCircuitBreaker oldBreaker, ESLogger logger) {
this.memoryBytesLimit = limit.bytes();
this.overheadConstant = overheadConstant;
if (oldBreaker == null) {
this.used = new AtomicLong(0);
this.trippedCount = new AtomicLong(0);
} else {
this.used = oldBreaker.used;
this.trippedCount = oldBreaker.trippedCount;
}
this.logger = logger;
if (logger.isTraceEnabled()) {
logger.trace("Creating MemoryCircuitBreaker with a limit of {} bytes ({}) and a overhead constant of {}",
this.memoryBytesLimit, limit, this.overheadConstant);
}
}
示例12: upgradeMultiDataPath
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
/**
* Runs an upgrade on all shards located under the given node environment if there is more than 1 data.path configured
* otherwise this method will return immediately.
*/
public static void upgradeMultiDataPath(NodeEnvironment nodeEnv, ESLogger logger) throws IOException {
if (nodeEnv.nodeDataPaths().length > 1) {
final MultiDataPathUpgrader upgrader = new MultiDataPathUpgrader(nodeEnv);
final Set<String> allIndices = nodeEnv.findAllIndices();
for (String index : allIndices) {
for (ShardId shardId : findAllShardIds(nodeEnv.indexPaths(new Index(index)))) {
try (ShardLock lock = nodeEnv.shardLock(shardId, 0)) {
if (upgrader.needsUpgrading(shardId)) {
final ShardPath shardPath = upgrader.pickShardPath(shardId);
upgrader.upgrade(shardId, shardPath);
// we have to check if the index path exists since we might
// have only upgraded the shard state that is written under /indexname/shardid/_state
// in the case we upgraded a dedicated index directory index
if (Files.exists(shardPath.resolveIndex())) {
upgrader.checkIndex(shardPath);
}
} else {
logger.debug("{} no upgrade needed - already upgraded", shardId);
}
}
}
}
}
}
示例13: checkUnsetAndMaybeExit
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
private static void checkUnsetAndMaybeExit(String confFileSetting, String settingName) {
if (confFileSetting != null && confFileSetting.isEmpty() == false) {
ESLogger logger = Loggers.getLogger(Bootstrap.class);
logger.info("{} is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed.", settingName);
exit(1);
}
}
示例14: SearchFactory
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
SearchFactory(ESLogger logger, AtomicBoolean isEngineClosed, EngineConfig engineConfig) {
super(engineConfig);
warmer = engineConfig.getWarmer();
shardId = engineConfig.getShardId();
this.logger = logger;
this.isEngineClosed = isEngineClosed;
}
示例15: checkUnsetAndMaybeExit
import org.elasticsearch.common.logging.ESLogger; //导入依赖的package包/类
private static void checkUnsetAndMaybeExit(String confFileSetting, String settingName) {
if (confFileSetting != null && confFileSetting.isEmpty() == false) {
ESLogger logger = Loggers.getLogger(Bootstrap.class);
logger.info("{} is no longer supported. crate.yml must be placed in the config directory and cannot be renamed.", settingName);
System.exit(1);
}
}