com.hazelcast.logging.ILogger Java Examples

The following examples show how to use com.hazelcast.logging.ILogger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PulsarSinkBuilder.java    From hazelcast-jet-contrib with Apache License 2.0 6 votes vote down vote up
private PulsarSinkContext(
        @Nonnull ILogger logger,
        @Nonnull String topic,
        @Nonnull PulsarClient client,
        @Nonnull Map<String, Object> producerConfig,
        @Nonnull SupplierEx<Schema<M>> schemaSupplier,
        @Nonnull FunctionEx<? super E, M> extractValueFn,
        @Nullable FunctionEx<? super E, String> extractKeyFn,
        @Nullable FunctionEx<? super E, Map<String, String>> extractPropertiesFn,
        @Nullable FunctionEx<? super E, Long> extractTimestampFn
) throws PulsarClientException {
    this.logger = logger;
    this.client = client;
    this.producer = client.newProducer(schemaSupplier.get())
                          .topic(topic)
                          .loadConf(producerConfig)
                          .create();
    this.extractKeyFn = extractKeyFn;
    this.extractValueFn = extractValueFn;
    this.extractPropertiesFn = extractPropertiesFn;
    this.extractTimestampFn = extractTimestampFn;
}
 
Example #2
Source File: TwitterSources.java    From hazelcast-jet-contrib with Apache License 2.0 6 votes vote down vote up
private TwitterStreamSourceContext(
        @Nonnull ILogger logger,
        @Nonnull Properties credentials,
        @Nonnull String host,
        @Nonnull SupplierEx<? extends StreamingEndpoint> endpointSupplier
) {
    this.logger = logger;
    checkTwitterCredentials(credentials);
    String consumerKey = credentials.getProperty("consumerKey");
    String consumerSecret = credentials.getProperty("consumerSecret");
    String token = credentials.getProperty("token");
    String tokenSecret = credentials.getProperty("tokenSecret");

    Authentication auth = new OAuth1(consumerKey, consumerSecret, token, tokenSecret);
    client = new ClientBuilder()
            .hosts(host)
            .endpoint(endpointSupplier.get())
            .authentication(auth)
            .processor(new StringDelimitedProcessor(queue))
            .build();
    client.connect();
}
 
Example #3
Source File: HazelcastKubernetesDiscoveryStrategy.java    From hazelcast-kubernetes with Apache License 2.0 6 votes vote down vote up
HazelcastKubernetesDiscoveryStrategy(ILogger logger, Map<String, Comparable> properties) {
    super(logger, properties);

    config = new KubernetesConfig(properties);
    logger.info(config.toString());

    client = buildKubernetesClient(config);

    if (DiscoveryMode.DNS_LOOKUP.equals(config.getMode())) {
        endpointResolver = new DnsEndpointResolver(logger, config.getServiceDns(), config.getServicePort(),
                config.getServiceDnsTimeout());
    } else {
        endpointResolver = new KubernetesApiEndpointResolver(logger, config.getServiceName(), config.getServicePort(),
                config.getServiceLabelName(), config.getServiceLabelValue(),
                config.getPodLabelName(), config.getPodLabelValue(),
                config.isResolveNotReadyAddresses(), client);
    }

    logger.info("Kubernetes Discovery activated with mode: " + config.getMode().name());
}
 
Example #4
Source File: SwarmAddressPicker.java    From hazelcast-docker-swarm-discovery-spi with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor
 */


public SwarmAddressPicker(final ILogger iLogger) {
    final String dockerNetworkNames = System.getProperty(PROP_DOCKER_NETWORK_NAMES);
    final String dockerServiceLabels = System.getProperty(PROP_DOCKER_SERVICE_LABELS);
    final String dockerServiceNames = System.getProperty(PROP_DOCKER_SERVICE_NAMES);
    final Integer hazelcastPeerPort = Integer.valueOf(System.getProperty(PROP_HAZELCAST_PEER_PORT));

    String swarmMgrUri = System.getProperty(PROP_SWARM_MGR_URI);
    if (swarmMgrUri == null || swarmMgrUri.trim().isEmpty()) {
        swarmMgrUri = System.getenv("DOCKER_HOST");
    }

    Boolean skipVerifySsl = false;
    if (System.getProperty(PROP_SKIP_VERIFY_SSL) != null) {
        skipVerifySsl = Boolean.valueOf(System.getProperty(PROP_SKIP_VERIFY_SSL));
    }

    initialize(iLogger, dockerNetworkNames, dockerServiceLabels, dockerServiceNames, hazelcastPeerPort, swarmMgrUri, skipVerifySsl);
}
 
Example #5
Source File: PulsarConsumerBuilder.java    From hazelcast-jet-contrib with Apache License 2.0 6 votes vote down vote up
private ConsumerContext(
        @Nonnull ILogger logger,
        @Nonnull PulsarClient client,
        @Nonnull List<String> topics,
        @Nonnull Map<String, Object> consumerConfig,
        @Nonnull SupplierEx<Schema<M>> schemaSupplier,
        @Nonnull SupplierEx<BatchReceivePolicy> batchReceivePolicySupplier,
        @Nonnull FunctionEx<Message<M>, T> projectionFn
) throws PulsarClientException {

    this.logger = logger;
    this.projectionFn = projectionFn;
    this.client = client;
    this.consumer = client.newConsumer(schemaSupplier.get())
                          .topics(topics)
                          .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
                          .loadConf(consumerConfig)
                          .batchReceivePolicy(batchReceivePolicySupplier.get())
                          .subscriptionType(SubscriptionType.Shared)
                          .subscribe();
}
 
Example #6
Source File: DoNothingRegistrator.java    From hazelcast-consul-discovery-spi with Apache License 2.0 6 votes vote down vote up
@Override
public void init(
		String consulHost, 
		Integer consulPort, 
		String consulServiceName, 
		String[] consulServiceTags, 
		String consulAclToken,  
		boolean consulSslEnabled,
		String	consulSslServerCertFilePath,
		String consulSslServerCertBase64,
		boolean consulServerHostnameVerify,
		DiscoveryNode localDiscoveryNode,
		Map<String, Object> registratorConfig, 
		ILogger logger) {

}
 
Example #7
Source File: PulsarReaderBuilder.java    From hazelcast-jet-contrib with Apache License 2.0 5 votes vote down vote up
private ReaderContext(
        @Nonnull ILogger logger,
        @Nonnull PulsarClient client,
        @Nonnull String topic,
        @Nonnull Map<String, Object> readerConfig,
        @Nonnull SupplierEx<Schema<M>> schemaSupplier,
        @Nonnull FunctionEx<Message<M>, T> projectionFn
) {
    this.logger = logger;
    this.client = client;
    this.topic = topic;
    this.readerConfig = readerConfig;
    this.schema = schemaSupplier.get();
    this.projectionFn = projectionFn;
}
 
Example #8
Source File: TracingUtils.java    From snowcast with Apache License 2.0 5 votes vote down vote up
public static Tracer tracer(Class<?> type) {
    if (!SnowcastConstants.LOGGING_ENABLED) {
        return NO_OP_TRACER;
    }
    ILogger logger = Logger.getLogger(type);
    return new TracerImpl(logger);
}
 
Example #9
Source File: TracingUtils.java    From snowcast with Apache License 2.0 5 votes vote down vote up
private static void log(ILogger logger, String message, Throwable throwable, Object arg1, Object arg2, Object arg3,
                        Object... args) {

    Object[] temp = new Object[args.length + 3];
    temp[0] = arg1;
    temp[1] = arg2;
    temp[2] = arg3;
    System.arraycopy(args, 0, temp, 3, args.length);
    log(logger, TRACE_LEVEL, message, throwable, temp);
}
 
Example #10
Source File: KubernetesApiEndpointResolver.java    From hazelcast-kubernetes with Apache License 2.0 5 votes vote down vote up
KubernetesApiEndpointResolver(ILogger logger, String serviceName, int port,
                              String serviceLabel, String serviceLabelValue, String podLabel, String podLabelValue,
                              Boolean resolveNotReadyAddresses, KubernetesClient client) {

    super(logger);

    this.serviceName = serviceName;
    this.port = port;
    this.serviceLabel = serviceLabel;
    this.serviceLabelValue = serviceLabelValue;
    this.podLabel = podLabel;
    this.podLabelValue = podLabelValue;
    this.resolveNotReadyAddresses = resolveNotReadyAddresses;
    this.client = client;
}
 
Example #11
Source File: DockerDNSRRDiscoveryStrategy.java    From hazelcast-docker-swarm-discovery-spi with Apache License 2.0 5 votes vote down vote up
public DockerDNSRRDiscoveryStrategy(
        ILogger logger,
        //The Comparable raw type is defined by AbstractDiscoveryStrategy as
        //the value for the properties element; passing through here
        @SuppressWarnings("rawtypes") Map<String, Comparable> properties
) {
    super(logger, properties);
    this.logger = logger;
}
 
Example #12
Source File: DockerDNSRRDiscoveryStrategyFactory.java    From hazelcast-docker-swarm-discovery-spi with Apache License 2.0 5 votes vote down vote up
@Override
public DiscoveryStrategy newDiscoveryStrategy(
        DiscoveryNode discoveryNode,
        ILogger logger,
        //Implementing DiscoveryStrategyFactory method with a raw type
        @SuppressWarnings("rawtypes") Map<String, Comparable> properties
) {
    return
            new DockerDNSRRDiscoveryStrategy(
                    logger,
                    properties
            );
}
 
Example #13
Source File: SwarmAddressPicker.java    From hazelcast-docker-swarm-discovery-spi with Apache License 2.0 5 votes vote down vote up
public SwarmAddressPicker(final ILogger iLogger, final String dockerNetworkNames, final String dockerServiceLabels,
                          final String dockerServiceNames, final Integer hazelcastPeerPort) {

    String swarmMgrUri = System.getenv("DOCKER_HOST");
    Boolean skipVerifySsl = false;

    initialize(iLogger, dockerNetworkNames, dockerServiceLabels, dockerServiceNames, hazelcastPeerPort, swarmMgrUri, skipVerifySsl);
}
 
Example #14
Source File: FlightDataSource.java    From hazelcast-jet-demos with Apache License 2.0 5 votes vote down vote up
private FlightDataSource(ILogger logger, String url, long pollIntervalMillis) {
    this.logger = logger;
    try {
        this.url = new URL(url);
    } catch (MalformedURLException e) {
        throw ExceptionUtil.rethrow(e);
    }
    this.pollIntervalMillis = pollIntervalMillis;
}
 
Example #15
Source File: TracingUtils.java    From snowcast with Apache License 2.0 4 votes vote down vote up
private static boolean isTracing(ILogger logger) {
    return loggingEnabled(logger, TRACE_LEVEL);
}
 
Example #16
Source File: TracingUtils.java    From snowcast with Apache License 2.0 4 votes vote down vote up
private static boolean loggingEnabled(ILogger logger, Level level) {
    return SnowcastConstants.LOGGING_ENABLED && logger.isLoggable(level);
}
 
Example #17
Source File: TracingUtils.java    From snowcast with Apache License 2.0 4 votes vote down vote up
private static void log(ILogger logger, Level level, String message, Throwable throwable, Object... args) {
    if (args.length > 0) {
        message = String.format(message, args);
    }
    logger.log(level, message, throwable);
}
 
Example #18
Source File: TracingUtils.java    From snowcast with Apache License 2.0 4 votes vote down vote up
private static void log(ILogger logger, String message, Throwable throwable, Object arg1, Object arg2) {
    log(logger, TRACE_LEVEL, message, throwable, new Object[]{arg1, arg2});
}
 
Example #19
Source File: TracingUtils.java    From snowcast with Apache License 2.0 4 votes vote down vote up
private static void log(ILogger logger, String message, Throwable throwable, Object arg1) {
    log(logger, TRACE_LEVEL, message, throwable, new Object[]{arg1});
}
 
Example #20
Source File: TracingUtils.java    From snowcast with Apache License 2.0 4 votes vote down vote up
private static void log(ILogger logger, String message, Throwable throwable) {
    log(logger, TRACE_LEVEL, message, throwable, EMPTY_ARGS);
}
 
Example #21
Source File: TracingUtils.java    From snowcast with Apache License 2.0 4 votes vote down vote up
private TracerImpl(ILogger logger) {
    this.logger = logger;
}
 
Example #22
Source File: HazelcastKubernetesDiscoveryStrategy.java    From hazelcast-kubernetes with Apache License 2.0 4 votes vote down vote up
EndpointResolver(ILogger logger) {
    this.logger = logger;
}
 
Example #23
Source File: HazelcastKubernetesDiscoveryStrategyFactory.java    From hazelcast-kubernetes with Apache License 2.0 4 votes vote down vote up
public DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode, ILogger logger,
                                              Map<String, Comparable> properties) {

    return new HazelcastKubernetesDiscoveryStrategy(logger, properties);
}
 
Example #24
Source File: DnsEndpointResolver.java    From hazelcast-kubernetes with Apache License 2.0 4 votes vote down vote up
DnsEndpointResolver(ILogger logger, String serviceDns, int port, DirContext dirContext) {
    super(logger);
    this.serviceDns = serviceDns;
    this.port = port;
    this.dirContext = dirContext;
}
 
Example #25
Source File: BaseRegistrator.java    From hazelcast-consul-discovery-spi with Apache License 2.0 4 votes vote down vote up
@Override
public void init(String consulHost, 
		         Integer consulPort,
		         String consulServiceName,
		         String[] consulTags,
		         String consulAclToken,
		         boolean consulSslEnabled,
				 String	consulSslServerCertFilePath,
				 String consulSslServerCertBase64,
				 boolean consulServerHostnameVerify,
		         DiscoveryNode localDiscoveryNode,
		         Map<String, Object> registratorConfig,
		         ILogger logger) throws Exception {
	
	this.logger = logger;
	this.tags = consulTags;
	this.consulHost = consulHost;
	this.consulPort = consulPort;
	this.consulServiceName = consulServiceName;
	this.consulAclToken = consulAclToken;
	this.registratorConfig = registratorConfig;
	
	try {
		/**
		 * Determine my local address
		 */
		this.myLocalAddress = determineMyLocalAddress(localDiscoveryNode, registratorConfig);
		logger.info("Determined local DiscoveryNode address to use: " + myLocalAddress);
		
		
		//Build our consul client to use. We pass in optional TLS information
		ConsulBuilder builder = ConsulClientBuilder.class.newInstance();
		Consul consul = builder.buildConsul(consulHost, 
											consulPort, 
											consulSslEnabled, 
											consulSslServerCertFilePath, 
											consulSslServerCertBase64, 
											consulServerHostnameVerify,
											consulAclToken);
		
		 
		// build my Consul agent client that we will register with
		this.consulAgentClient =  consul.agentClient();
		
	} catch(Exception e) {
		String msg = "Unexpected error in configuring LocalDiscoveryNodeRegistration: " + e.getMessage();
		logger.severe(msg,e);
		throw new Exception(msg,e);
	}
	
}
 
Example #26
Source File: ConsulDiscoveryStrategyFactory.java    From hazelcast-consul-discovery-spi with Apache License 2.0 4 votes vote down vote up
public DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode,
											  ILogger logger,
											  Map<String, Comparable> properties ) {

	return new ConsulDiscoveryStrategy( discoveryNode, logger, properties );                                      
}
 
Example #27
Source File: DockerSwarmDiscoveryStrategyFactory.java    From hazelcast-docker-swarm-discovery-spi with Apache License 2.0 4 votes vote down vote up
public DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode,
                                              ILogger logger,
                                              Map<String, Comparable> properties) {

    return new DockerSwarmDiscoveryStrategy(discoveryNode, logger, properties);
}
 
Example #28
Source File: ConsulRegistrator.java    From hazelcast-consul-discovery-spi with Apache License 2.0 3 votes vote down vote up
/**
 * Initialize the registrator
 * 
 * @param consulHost
 * @param consulPort
 * @param consulServiceName
 * @param consulTags
 * @param consulAclToken
 * @param consulSslEnabled
 * @param consulSslServerCertFilePath
 * @param consulSslServerCertBase64
 * @param consulServerHostnameVerify
 * @param localDiscoveryNode
 * @param registratorConfig
 * @param logger
 * @throws Exception
 */
public void init(String consulHost, 
		         Integer consulPort,
		         String consulServiceName,
		         String[] consulTags,
		         String consulAclToken,
		         boolean consulSslEnabled,
				 String	consulSslServerCertFilePath,
				 String consulSslServerCertBase64,
				 boolean consulServerHostnameVerify,
		         DiscoveryNode localDiscoveryNode,
		         Map<String, Object> registratorConfig,
		         ILogger logger) throws Exception;
 
Example #29
Source File: DnsEndpointResolver.java    From hazelcast-kubernetes with Apache License 2.0 2 votes vote down vote up
DnsEndpointResolver(ILogger logger, String serviceDns, int port, int serviceDnsTimeout) {
    this(logger, serviceDns, port, createDirContext(serviceDnsTimeout));

}
 
Example #30
Source File: TracingUtils.java    From snowcast with Apache License 2.0 2 votes vote down vote up
private static void log(ILogger logger, String message, Throwable throwable, Object arg1, Object arg2, Object arg3) {

        log(logger, TRACE_LEVEL, message, throwable, new Object[]{arg1, arg2, arg3});
    }