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

Java Service类代码示例

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

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



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

示例1: runQuery

import com.splunk.Service; //导入依赖的package包/类
private List<SplunkEvent> runQuery(JobArgs queryArgs, boolean realtime, SplunkResultProcessor callback) throws Exception {
    Service service = endpoint.getService();
    Job job = service.getJobs().create(getSearch(), queryArgs);
    LOG.debug("Running search : {} with queryArgs : {}", getSearch(), queryArgs);
    if (realtime) {
        while (!job.isReady()) {
            Thread.sleep(500);
        }
        // Besides job.isReady there must be some delay before real time job
        // is ready
        // TODO seems that the realtime stream is not quite isReady to be
        // read
        Thread.sleep(4000);
    } else {
        while (!job.isDone()) {
            Thread.sleep(500);
        }
    }
    return extractData(job, realtime, callback);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:SplunkDataReader.java


示例2: createSocket

import com.splunk.Service; //导入依赖的package包/类
@Override
protected Socket createSocket(Service service) throws IOException {
    Index indexObject = null;
    Receiver receiver = null;
    Socket socket = null;

    if (index != null) {
        indexObject = service.getIndexes().get(index);
        if (indexObject == null) {
            throw new RuntimeCamelException(String.format("cannot find index [%s]", index));
        }
        socket = indexObject.attach(args);
    } else {
        receiver = service.getReceiver();
        socket = receiver.attach(args);
    }
    socket.setTcpNoDelay(true);
    LOG.trace(String.format("created a socket on %s", socket.getRemoteSocketAddress()));
    return socket;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:StreamDataWriter.java


示例3: createConsumerEndpointWithMaximalConfiguration

import com.splunk.Service; //导入依赖的package包/类
@Test
public void createConsumerEndpointWithMaximalConfiguration() throws Exception {
    SplunkComponent component = context.getComponent("splunk", SplunkComponent.class);

    SplunkEndpoint endpoint = (SplunkEndpoint)component
        .createEndpoint("splunk://normal?username=test&password=pw&host=myhost&port=3333&delay=10s&" + "search=Splunk search query goes here&initEarliestTime=-1d"
                        + "&latestTime=now&count=10&" + "owner=me&app=fantasticapp");
    assertEquals("myhost", endpoint.getConfiguration().getHost());
    assertEquals(3333, endpoint.getConfiguration().getPort());
    assertEquals("test", endpoint.getConfiguration().getUsername());
    assertEquals("pw", endpoint.getConfiguration().getPassword());
    assertEquals("-1d", endpoint.getConfiguration().getInitEarliestTime());
    assertEquals("now", endpoint.getConfiguration().getLatestTime());
    assertEquals(10, endpoint.getConfiguration().getCount());
    assertEquals("me", endpoint.getConfiguration().getOwner());
    assertEquals("fantasticapp", endpoint.getConfiguration().getApp());
    assertEquals(Service.DEFAULT_SCHEME, endpoint.getConfiguration().getScheme());
    assertEquals("Splunk search query goes here", endpoint.getConfiguration().getSearch());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:SplunkComponentConfigurationTest.java


示例4: connect

import com.splunk.Service; //导入依赖的package包/类
/**
 * Create connection with the splunk server.
 */
@Override
public void connect()
{
  try {
    ServiceArgs loginArgs = new ServiceArgs();
    loginArgs.setUsername(userName);
    loginArgs.setPassword(password);
    loginArgs.setHost(host);
    loginArgs.setPort(port);

    service = Service.connect(loginArgs);
  } catch (Exception e) {
    throw new RuntimeException("closing connection", e);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:19,代码来源:SplunkStore.java


示例5: getAvailability

import com.splunk.Service; //导入依赖的package包/类
/**
 * Returns UP if the information can be obtained and
 * the metrics file can be read.
 */
@Override
public AvailabilityType getAvailability() {
    try {
        log.debug("probe");
        Service service = SplunkDiscovery.service(config);
        serviceInfo = service.getInfo();
        service.logout();
        /*
        Splunk file rotation makes the metrics file unreadable
        This is Splunk case 117457
        log.debug("tail");
        tail.read();
        */
        log.debug("done");
        return AvailabilityType.UP;
    } catch (Exception e) {
        log.debug("failed checking splunk", e);
        return AvailabilityType.DOWN;
    }
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:25,代码来源:SplunkComponent.java


示例6: getNumberOfResultsFromJob

import com.splunk.Service; //导入依赖的package包/类
public int getNumberOfResultsFromJob(SplunkConf conf) {
    Service service = job.getService();
    String searchString = job.getSearch();
    searchString = searchString.concat(" | stats count");
    SplunkConf newConfig = new SplunkConf(conf);
    newConfig.set(SplunkConf.SPLUNK_SEARCH_QUERY,searchString);

    SplunkJob getEvents = SplunkJob.createSplunkJob(service,newConfig);
    getEvents.waitForCompletion(100);

    JobResultsArgs resultsArgs = new JobResultsArgs();
    resultsArgs.setOutputMode(JobResultsArgs.OutputMode.CSV);
    resultsArgs.setFieldList(new String[] {"count"});

    BufferedReader br = new BufferedReader(new InputStreamReader(getEvents.getJob().getResults(resultsArgs)));
    try {
        br.readLine(); // Skip header
        return Integer.parseInt(br.readLine());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:23,代码来源:SplunkJob.java


示例7: createSocket

import com.splunk.Service; //导入依赖的package包/类
@Override
protected Socket createSocket(Service service) throws IOException {
    TcpInput input = (TcpInput)service.getInputs().get(String.valueOf(port));
    if (input == null) {
        throw new RuntimeException("no input defined for port " + port);
    }
    if (input.isDisabled()) {
        throw new RuntimeException(String.format("input on port %d is disabled", port));
    }
    return input.attach();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:TcpDataWriter.java


示例8: createProducerEndpointWithMinimalConfiguration

import com.splunk.Service; //导入依赖的package包/类
@Test
public void createProducerEndpointWithMinimalConfiguration() throws Exception {
    SplunkComponent component = context.getComponent("splunk", SplunkComponent.class);

    SplunkEndpoint endpoint = (SplunkEndpoint)component.createEndpoint("splunk://test?username=test&password=pw");
    assertEquals(Service.DEFAULT_HOST, endpoint.getConfiguration().getHost());
    assertEquals(Service.DEFAULT_PORT, endpoint.getConfiguration().getPort());
    assertEquals("test", endpoint.getConfiguration().getUsername());
    assertEquals("pw", endpoint.getConfiguration().getPassword());
    assertEquals(Service.DEFAULT_SCHEME, endpoint.getConfiguration().getScheme());
    assertEquals(5000, endpoint.getConfiguration().getConnectionTimeout());
    assertFalse(endpoint.getConfiguration().isUseSunHttpsHandler());
    assertFalse(endpoint.getConfiguration().isRaw());
    assertEquals(SSLSecurityProtocol.TLSv1_2, endpoint.getConfiguration().getSslProtocol());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:SplunkComponentConfigurationTest.java


示例9: createConsumerEndpointWithMinimalConfiguration

import com.splunk.Service; //导入依赖的package包/类
@Test
public void createConsumerEndpointWithMinimalConfiguration() throws Exception {
    SplunkComponent component = context.getComponent("splunk", SplunkComponent.class);

    SplunkEndpoint endpoint = (SplunkEndpoint)component.createEndpoint("splunk://realtime?username=test&" + "password=pw&search=Splunk search query goes here");
    assertEquals(Service.DEFAULT_HOST, endpoint.getConfiguration().getHost());
    assertEquals(Service.DEFAULT_PORT, endpoint.getConfiguration().getPort());
    assertEquals("test", endpoint.getConfiguration().getUsername());
    assertEquals("pw", endpoint.getConfiguration().getPassword());
    assertEquals(Service.DEFAULT_SCHEME, endpoint.getConfiguration().getScheme());
    assertEquals(5000, endpoint.getConfiguration().getConnectionTimeout());
    assertEquals("Splunk search query goes here", endpoint.getConfiguration().getSearch());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:SplunkComponentConfigurationTest.java


示例10: mockComponent

import com.splunk.Service; //导入依赖的package包/类
public static DefaultSplunkConfigurationFactory mockComponent(final Service service, final Socket socket) {
    return new DefaultSplunkConfigurationFactory() {
        @Override
        public SplunkConfiguration parseMap(Map<String, Object> parameters) {
            return new MockConnectionSettings(service, socket);
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:Helper.java


示例11: SplunkReporter

import com.splunk.Service; //导入依赖的package包/类
public SplunkReporter(Builder builder, Service splunk) {
    super(builder.registry, builder.prefix, builder.filter, builder.rateUnit, builder.durationUnit);
    receiver = splunk.getReceiver();
    this.showSamples = builder.showSamples;
    splunkArgs.put("source", builder.source);
    splunkArgs.put("sourcetype", builder.sourcetype);
    this.index = builder.index;
    this.extraAttributes = builder.extraAttributes;
    mapper = new ObjectMapper().registerModule(new MetricsModule(builder.rateUnit, builder.durationUnit, this.showSamples));
}
 
开发者ID:zenmoto,项目名称:metrics-splunk,代码行数:11,代码来源:SplunkReporter.java


示例12: getService

import com.splunk.Service; //导入依赖的package包/类
public Service getService() {
    if (service == null) {
        this.service = configuration.getConnectionFactory().createService(getCamelContext());
    }
    return service;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:SplunkEndpoint.java


示例13: MockConnectionSettings

import com.splunk.Service; //导入依赖的package包/类
MockConnectionSettings(Service service, Socket socket) {
    this.service = service;
    this.socket = socket;
    mockSplunkWriterApi();
    setConnectionFactory(new MockConnectionFactory(service));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:Helper.java


示例14: MockConnectionFactory

import com.splunk.Service; //导入依赖的package包/类
MockConnectionFactory(Service service) {
    super("foo", "bar");
    this.service = service;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:Helper.java


示例15: createService

import com.splunk.Service; //导入依赖的package包/类
@Override
public Service createService(CamelContext camelContext) {
    return service;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:Helper.java


示例16: getService

import com.splunk.Service; //导入依赖的package包/类
public Service getService()
{
  return service;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:5,代码来源:SplunkStore.java


示例17: setup

import com.splunk.Service; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    splunk = mock(Service.class);
    receiver = mock(Receiver.class);
    when(splunk.getReceiver()).thenReturn(receiver);

    reg = new MetricRegistry();

    reg.counter("tcounter").inc();
    reg.meter("tmeter").mark();
    reg.histogram("thist").update(10);
    reg.histogram("thist").update(1);
    reg.timer("ttimer").time().stop();
}
 
开发者ID:zenmoto,项目名称:metrics-splunk,代码行数:15,代码来源:SplunkReporterTest.java


示例18: main

import com.splunk.Service; //导入依赖的package包/类
public static void main(String[] args) {
	// Create login parameters. We suggest finding
	// a better way to store these than hard coding
	// them in your program for production code.
	ServiceArgs serviceArgs = new ServiceArgs();
	serviceArgs.setUsername("admin");
	serviceArgs.setPassword("changeme");
	serviceArgs.setHost("localhost");
	serviceArgs.setPort(8089);

	// Create a Service instance and log in with the argument map
	Service service = Service.connect(serviceArgs);
	
	// Set the parameters for the search
	Args oneshotSearchArgs = new Args();
	// For a full list of options, see:
	//
	//     http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#POST_search.2Fjobs

	// oneshotSearchArgs.put("earliest_time", "now-1w");
	// oneshotSearchArgs.put("latest_time",   "now");

	InputStream resultsStream = service.oneshotSearch("search * | head 5",
			oneshotSearchArgs);

	try {
		ResultsReaderXml resultsReader = new ResultsReaderXml(resultsStream);

		for (Event event : resultsReader) {
			// Process each event
			for (String key: event.keySet()) {
			   System.out.println(key + ": " + event.get(key));
			}
			System.out.println("");
		}

		resultsReader.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:splunk,项目名称:splunk-plugin-eclipse,代码行数:42,代码来源:Program.java


示例19: getSplunkJob

import com.splunk.Service; //导入依赖的package包/类
public static SplunkJob getSplunkJob(Service service, String jobId) {
    Job job = service.getJobs().get(jobId);
    return new SplunkJob(job);
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:5,代码来源:SplunkJob.java


示例20: connect

import com.splunk.Service; //导入依赖的package包/类
public static Service connect(SplunkConf configuration) {
    return connect(
            configuration.get(SplunkConf.SPLUNK_USERNAME),
            configuration.get(SplunkConf.SPLUNK_PASSWORD),
            configuration.get(SplunkConf.SPLUNK_HOST),
            configuration.getInt(SplunkConf.SPLUNK_PORT, 8080));
}
 
开发者ID:yolodata,项目名称:tbana,代码行数:8,代码来源:SplunkService.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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