当前位置: 首页>>代码示例>>Java>>正文


Java Service类代码示例

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


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


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