• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InputLogEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.logs.model.InputLogEvent的典型用法代码示例。如果您正苦于以下问题:Java InputLogEvent类的具体用法?Java InputLogEvent怎么用?Java InputLogEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InputLogEvent类属于com.amazonaws.services.logs.model包,在下文中一共展示了InputLogEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: compare

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
@Override
public int compare(InputLogEvent o1, InputLogEvent o2) {
	if (o1.getTimestamp() == null) {
		if (o2.getTimestamp() == null) {
			return 0;
		} else {
			// null - long
			return -1;
		}
	} else if (o2.getTimestamp() == null) {
		// long - null
		return 1;
	} else {
		return o1.getTimestamp().compareTo(o2.getTimestamp());
	}
}
 
开发者ID:j256,项目名称:cloudwatch-logback-appender,代码行数:17,代码来源:CloudWatchAppender.java


示例2: flush

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private void flush(boolean all) {
    try {
        long lostCount = this.lostCount.getAndSet(0);
        if (lostCount > 0) {
            getAwsLogsAppender().addWarn(lostCount + " events lost");
        }
        if (!queue.isEmpty()) {
            do {
                Collection<InputLogEvent> batch = drainBatchFromQueue();
                getAwsLogsAppender().getAwsLogsStub().logEvents(batch);
            } while (queue.size() >= maxBatchLogEvents || (all && !queue.isEmpty()));
        }
    } catch (Exception e) {
        getAwsLogsAppender().addError("Unable to flush events to AWS", e);
    }
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:17,代码来源:AsyncWorker.java


示例3: flush

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private void flush() {
    int drained;
    final List<InputLogEvent> logEvents = new ArrayList<>(AWS_DRAIN_LIMIT);
    do {
        drained = queue.drainTo(logEvents, AWS_DRAIN_LIMIT);
        if (logEvents.isEmpty()) {
            break;
        }
        logEvents.sort(Comparator.comparing(InputLogEvent::getTimestamp));
        if (lastReportedTimestamp > 0) {
            for (final InputLogEvent event : logEvents) {
                if (event.getTimestamp() < lastReportedTimestamp) {
                    event.setTimestamp(lastReportedTimestamp);
                }
            }
        }

        lastReportedTimestamp = logEvents.get(logEvents.size() - 1).getTimestamp();
        final PutLogEventsRequest putLogEventsRequest = new PutLogEventsRequest(logGroupName, logStreamName, logEvents);
        putLogEventsRequest.setSequenceToken(sequenceTokenCache);
        try {
            final PutLogEventsResult putLogEventsResult = awsLogsClient.putLogEvents(putLogEventsRequest);
            sequenceTokenCache = putLogEventsResult.getNextSequenceToken();
        } catch (final DataAlreadyAcceptedException daae) {
            sequenceTokenCache = daae.getExpectedSequenceToken();
        } catch (final InvalidSequenceTokenException iste) {
            sequenceTokenCache = iste.getExpectedSequenceToken();
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
        }
        logEvents.clear();
    } while (drained >= AWS_DRAIN_LIMIT);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:34,代码来源:CloudWatchAppender.java


示例4: append

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
@Override
public void append(final LogEvent logEvent) {
    final LogEvent event = LoggingUtils.prepareLogEvent(logEvent);
    final InputLogEvent awsLogEvent = new InputLogEvent();
    final long timestamp = event.getTimeMillis();
    final String message = new String(getLayout().toByteArray(event));
    awsLogEvent.setTimestamp(timestamp);
    awsLogEvent.setMessage(message);
    if (!queue.offer(awsLogEvent) && !queueFull) {
        queueFull = true;
    } else if (queueFull) {
        queueFull = false;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:15,代码来源:CloudWatchAppender.java


示例5: append

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
@Override
protected void append(final ILoggingEvent event) {
    synchronized (lockObject) {
        eventQueue.add(new InputLogEvent()
                .withTimestamp(event.getTimeStamp())
                .withMessage(layout.doLayout(event)));
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:9,代码来源:CloudWatchAppender.java


示例6: getBatch

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private Collection<InputLogEvent> getBatch() {
    synchronized (lockObject) {
        final Collection<InputLogEvent> result = new ArrayList<>(eventQueue);
        eventQueue.clear();
        return result;
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:8,代码来源:CloudWatchAppender.java


示例7: asInputLogEvent

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
InputLogEvent asInputLogEvent(ILoggingEvent event) {
    InputLogEvent inputLogEvent = new InputLogEvent().withTimestamp(event.getTimeStamp())
            .withMessage(awsLogsAppender.getLayout().doLayout(event));

    if (eventSize(inputLogEvent) > MAX_EVENT_SIZE) {
        awsLogsAppender
                .addWarn(String.format("Log message exceeded Cloudwatch Log's limit of %d bytes", MAX_EVENT_SIZE));
        trimMessage(inputLogEvent, MAX_EVENT_SIZE);
    }

    return inputLogEvent;
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:13,代码来源:Worker.java


示例8: trimMessage

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private static final void trimMessage(InputLogEvent event, int eventSize) {
    int trimmedMessageSize = eventSize - EVENT_SIZE_PADDING - ELLIPSIS.getBytes(EVENT_SIZE_CHARSET).length;
    byte[] message = event.getMessage().getBytes(EVENT_SIZE_CHARSET);

    String unsafeTrimmed = new String(message, 0, trimmedMessageSize + 1, EVENT_SIZE_CHARSET);
    // The last character might be a chopped UTF-8 character
    String trimmed = unsafeTrimmed.substring(0, unsafeTrimmed.length() - 1);

    event.setMessage(trimmed + ELLIPSIS);
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:11,代码来源:Worker.java


示例9: AsyncWorker

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
AsyncWorker(AwsLogsAppender awsLogsAppender) {
    super(awsLogsAppender);
    maxBatchLogEvents = awsLogsAppender.getMaxBatchLogEvents();
    discardThreshold = (int) Math.ceil(maxBatchLogEvents * 1.5);
    running = new AtomicBoolean(false);
    queue = new ArrayBlockingQueue<InputLogEvent>(maxBatchLogEvents * 2);
    lostCount = new AtomicLong(0);
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:9,代码来源:AsyncWorker.java


示例10: drainBatchFromQueue

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private Collection<InputLogEvent> drainBatchFromQueue() {
    Deque<InputLogEvent> batch = new ArrayDeque<InputLogEvent>(maxBatchLogEvents);
    queue.drainTo(batch, MAX_BATCH_LOG_EVENTS);
    int batchSize = batchSize(batch);
    while (batchSize > MAX_BATCH_SIZE) {
        InputLogEvent removed = batch.removeLast();
        batchSize -= eventSize(removed);
        if (!queue.offer(removed)) {
            getAwsLogsAppender().addWarn("Failed requeing message from too big batch");
        }
    }
    return batch;
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:14,代码来源:AsyncWorker.java


示例11: batchSize

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private static int batchSize(Collection<InputLogEvent> batch) {
    int size = 0;
    for (InputLogEvent event : batch) {
        size += eventSize(event);
    }
    return size;
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:8,代码来源:AsyncWorker.java


示例12: verifyLogRequests

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private void verifyLogRequests(List<CloudWatchLogger.LogRequest> logRequests, EventTag eventTag) {
    List<String> unpackedLines = new ArrayList<>();

    for (CloudWatchLogger.LogRequest logRequest : logRequests) {
        for (InputLogEvent logEvent : logRequest.getLogEvents()) {
            unpackedLines.add(logEvent.getMessage());
        }
    }
    assertThat(unpackedLines, equalTo(eventTag.getEvents()));
}
 
开发者ID:Cantara,项目名称:ConfigService,代码行数:11,代码来源:CloudWatchLoggerTest.java


示例13: sendEvent

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private void sendEvent(String message) {

		List<InputLogEvent> logEvents = new LinkedList<>();
		logEvents.add(new InputLogEvent().withTimestamp(new Date().getTime()).withMessage(message));

		PutLogEventsRequest putLogEventsRequest = new PutLogEventsRequest(logGroupName, logStreamName, logEvents);
		putLogEventsRequest.setSequenceToken(lastSequenceToken);

		PutLogEventsResult putLogEventsResult = awsLogsClient.putLogEvents(putLogEventsRequest);
		lastSequenceToken = putLogEventsResult.getNextSequenceToken();
	}
 
开发者ID:Bankmonitor,项目名称:logback-appenders,代码行数:12,代码来源:AwsLogsJsonAppender.java


示例14: testBasic

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
@Test(timeout = 5000)
public void testBasic() throws InterruptedException {
	CloudWatchAppender appender = new CloudWatchAppender();
	AWSLogsClient awsLogClient = createMock(AWSLogsClient.class);
	appender.setAwsLogsClient(awsLogClient);

	appender.setMaxBatchSize(1);
	appender.setRegion("region");
	final String logGroup = "pfqoejpfqe";
	appender.setLogGroup(logGroup);
	final String logStream = "pffqjfqjpoqoejpfqe";
	appender.setLogStream(logStream);
	PatternLayout layout = new PatternLayout();
	layout.setContext(new LoggerContext());
	layout.setPattern("[%thread] %level %logger{20} - %msg%n%xThrowable");
	layout.start();
	appender.setLayout(layout);

	LoggingEvent event = new LoggingEvent();
	event.setTimeStamp(System.currentTimeMillis());
	String loggerName = "name";
	event.setLoggerName(loggerName);
	Level level = Level.DEBUG;
	event.setLevel(level);
	String message = "fjpewjfpewjfpewjfepowf";
	event.setMessage(message);

	String threadName = Thread.currentThread().getName();
	final String fullMessage = "[" + threadName + "] " + level + " " + loggerName + " - " + message + "\n";

	final PutLogEventsResult result = new PutLogEventsResult();
	String sequence = "ewopjfewfj";
	result.setNextSequenceToken(sequence);
	expect(awsLogClient.putLogEvents(isA(PutLogEventsRequest.class))).andAnswer(new IAnswer<PutLogEventsResult>() {
		@Override
		public PutLogEventsResult answer() {
			PutLogEventsRequest request = (PutLogEventsRequest) getCurrentArguments()[0];
			assertEquals(logGroup, request.getLogGroupName());
			assertEquals(logStream, request.getLogStreamName());
			List<InputLogEvent> events = request.getLogEvents();
			assertEquals(1, events.size());
			assertEquals(fullMessage, events.get(0).getMessage());
			return result;
		}
	}).times(2);
	awsLogClient.shutdown();

	// =====================================

	replay(awsLogClient);
	appender.start();
	// for coverage
	appender.start();
	appender.append(event);
	Thread.sleep(10);
	appender.append(event);
	while (appender.getEventsWrittenCount() < 2) {
		Thread.sleep(10);
	}
	appender.stop();
	verify(awsLogClient);
}
 
开发者ID:j256,项目名称:cloudwatch-logback-appender,代码行数:63,代码来源:CloudWatchAppenderTest.java


示例15: testMessageErrorHandling

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
@Test
public void testMessageErrorHandling() throws Exception
{
    // WARNING: this test may break if the internal implementation changes

    initialize("TestCloudWatchAppender/testMessageErrorHandling.properties");

    // the mock client -- will throw on odd invocations
    MockCloudWatchClient mockClient = new MockCloudWatchClient()
    {
        @Override
        protected PutLogEventsResult putLogEvents(PutLogEventsRequest request)
        {
            if (putLogEventsInvocationCount % 2 == 1)
            {
                throw new TestingException("anything");
            }
            else
            {
                return super.putLogEvents(request);
            }
        }
    };

    appender.setThreadFactory(new DefaultThreadFactory());
    appender.setWriterFactory(mockClient.newWriterFactory());

    for (int ii = 0 ; ii < 10 ; ii++)
    {
        logger.debug("message " + ii);
    }

    mockClient.allowWriterThread();

    assertEquals("first batch, number of events in request", 10, mockClient.mostRecentEvents.size());

    List<InputLogEvent> preservedEvents = new ArrayList<InputLogEvent>(mockClient.mostRecentEvents);

    // the first batch should have been returned to the message queue, in order

    mockClient.allowWriterThread();

    assertEquals("second batch, number of events in request", 10, mockClient.mostRecentEvents.size());

    for (int ii = 0 ; ii < mockClient.mostRecentEvents.size() ; ii++)
    {
        assertEquals("event #" + ii, preservedEvents.get(ii), mockClient.mostRecentEvents.get(ii));
    }

    // now assert that those messages will not be resent

    for (int ii = 100 ; ii < 102 ; ii++)
    {
        logger.debug("message " + ii);
    }

    mockClient.allowWriterThread();

    assertEquals("third batch, number of events in request", 2, mockClient.mostRecentEvents.size());
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:61,代码来源:TestCloudWatchAppender.java


示例16: eventSize

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
static final int eventSize(InputLogEvent event) {
    return event.getMessage().getBytes(EVENT_SIZE_CHARSET).length + EVENT_SIZE_PADDING;
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:4,代码来源:Worker.java


示例17: append

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
@Override
public void append(ILoggingEvent event) {
    // don't log if discardThreshold is met and event is not important (< WARN)
    if (queue.size() >= discardThreshold && !event.getLevel().isGreaterOrEqual(Level.WARN)) {
        lostCount.incrementAndGet();
        synchronized (running) {
            running.notifyAll();
        }
        return;
    }
    InputLogEvent logEvent = asInputLogEvent(event);
    // are we allowed to block ?
    if (getAwsLogsAppender().getMaxBlockTimeMillis() > 0) {
        // we are allowed to block, offer uninterruptibly for the configured maximum blocking time
        boolean interrupted = false;
        long until = System.currentTimeMillis() + getAwsLogsAppender().getMaxBlockTimeMillis();
        try {
            long now = System.currentTimeMillis();
            while (now < until) {
                try {
                    if (!queue.offer(logEvent, until - now, TimeUnit.MILLISECONDS)) {
                        lostCount.incrementAndGet();
                    }
                    break;
                } catch (InterruptedException e) {
                    interrupted = true;
                    now = System.currentTimeMillis();
                }
            }
        } finally {
            if (interrupted) {
                Thread.currentThread().interrupt();
            }
        }
    } else {
        // we are not allowed to block, offer without blocking
        if (!queue.offer(logEvent)) {
            lostCount.incrementAndGet();
        }
    }
    // trigger a flush if queue is full
    if (queue.size() >= maxBatchLogEvents) {
        synchronized (running) {
            running.notifyAll();
        }
    }
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:48,代码来源:AsyncWorker.java


示例18: anyInputLogEvents

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
private static Collection<InputLogEvent> anyInputLogEvents() {
    return anyCollection();
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:4,代码来源:AsyncWorkerTest.java


示例19: eventShouldNotBeTrimmed

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
@Theory
public void eventShouldNotBeTrimmed(@FromDataPoints("UNTRIMMED") String message) {
    InputLogEvent event = worker.asInputLogEvent(asEvent(message));
    assertFalse(event.getMessage().endsWith("..."));
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:6,代码来源:WorkerTest.java


示例20: eventShouldBeTrimmed

import com.amazonaws.services.logs.model.InputLogEvent; //导入依赖的package包/类
@Theory
public void eventShouldBeTrimmed(@FromDataPoints("TRIMMED") String message) {
    InputLogEvent event = worker.asInputLogEvent(asEvent(message));
    assertTrue(event.getMessage().endsWith("..."));
}
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:6,代码来源:WorkerTest.java



注:本文中的com.amazonaws.services.logs.model.InputLogEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FrictionJointDef类代码示例发布时间:2022-05-23
下一篇:
Java ClassDump类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap