How to user KafkaAdminClient to set Quota limits? - java

I find alterConfigs in KafkaAdminClient,So I want to set Quota limits via KafkaAdminClient, Can it even possible? and How to set the config Map?
Thanks.

Currently, quota-related broker configs can only be updated using Zookeeper(namely by ConfigCommand). Users cannot set these values by AdminClient. KIP-248 will migrate all of the functions to the new AdminClient. See it for more details.

Related

Elastic apm - Disable transaction/span programatically for specific endpoint

I am using elastic-apm with spring application to monitor API requests and track all SQL's executed for given endpoint. The problem is give the amount of traffic elastic search is collecting huge magnitude of data and I would like to enable capturing span only for specific endpoints.
I tried using public api of elastic-apm https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html
I can customize a transaction and span but I couldn't find a way to enable/disable to specific endpoints.
I have tried this but no luck -
ElasticApm.currentSpan().startSpan();
ElasticApm.currentSpan().end();
Looks like it can be done using drop_event processor in api-server.yml.
processors:
- drop_event:
when:
equals:
transaction.custom.transactions_sampled: false
and in code set custom context:
Transaction elasticTransaction = ElasticApm.currentTransaction();
elasticTransaction.addCustomContext("transactions.sampled", false);

Fetching info from JVM MBeans

I was trying to fetch the below details for my monitoring application using JVM MBeans
thread-states.blocked
thread-states.waiting
gc.ConcurrentMarkSweep.runs
gc.ParNew.runs
thread_count
daemon_thread_count
memory.heap_usage
memory.non_heap_usage
I am able to fetch most of them except
thread-states.blocked
thread-states.waiting
gc.ConcurrentMarkSweep.runs
gc.ParNew.runs
Does anybody know what MBean and attribute can be used to collect these values?
PS: i have googled this before posting it here
thread-states.blocked
thread-states.waiting
you can use getAllThreadIds() and get each Thread's information getThreadInfo() and filter based on the state
gc.ConcurrentMarkSweep.runs
gc.ParNew.runs
get getGarbageCollectorMXBeans() filter them for CMS and ParNew and getCollectionCount()

Spring IAMP Mail receiver not reading all emails everytime [duplicate]

I have a piece of code which uses spring integration's IMAP adapter to poll an inbox to read all incoming emails which are unread and that works perfectly. But if I open any email message and and then mark it as "unread" in my outlook inbox the poller doesn't fetch the marked email.
I can use the pop3 adapter which fetches all the email, but deletes them afterwords, but I want to keep the emails in my inbox and I want the poller to fetch all the email which are unseen.
Any suggestions to handle this problem? I been searching and reading articles on email adapters but didn't find anything useful.
Thanks in advance.
Looks like you need custom 'search-term-strategy'. From Spring Integration (SI) documentation:
By default, the ImapMailReceiver will search for Messages based on the default SearchTerm which is All mails that are RECENT (if supported), that are NOT ANSWERED, that are NOT DELETED, that are NOT SEEN and have not been processed by this mail receiver (enabled by the use of the custom USER flag or simply NOT FLAGGED if not supported). Since version 2.2, the SearchTerm used by the ImapMailReceiver is fully configurable via the SearchTermStrategy which you can inject via the search-term-strategy attribute. SearchTermStrategy is a simple strategy interface with a single method that allows you to create an instance of the SearchTerm that will be used by the ImapMailReceiver.
And here is a post from SI forum with funtastic Oleg's explanation: Server does not support RECENT or USER flags
And here you can find SI DefaultSearchTermStrategy: it's a place to determine how you should implement your own strategy. I guess, you case is:
This email server does not support RECENT flag, but it does support USER flags which will be used to prevent duplicates during email fetch.
Switch SI-mail logging level to DEBUG and take a look, which flag supports your email server.

In java, how can I get an Amazon EC2 Instance to see its own tags?

So I have a java program running within an Amazon EC2 instance. Is there a way to programatically get its own tags? I have tried instantiating a new AmazonEC2Client to us the describeTags() function but it only gives me null. Any help would be appreciated thank you.
Edit: To make things clearer, the instances are going to be unmanned worker machines spun up to solely do some computations
This should help you get started...
String instanceId = EC2MetadataUtils.getInstanceId();
AmazonEC2 client = AmazonEC2ClientBuilder.standard()
.withCredentials(new DefaultAWSCredentialsProviderChain())
.build();
DescribeTagsRequest req = new DescribeTagsRequest()
.withFilters(new Filter("resource-id", Collections.singletonList(instanceId)));
DescribeTagsResult describeTagsResult = client.describeTags(req);
List<TagDescription> tags = describeTagsResult.getTags()
You should be able to get the current instance id by sending a request to: http://169.254.169.254/latest/meta-data/instance-id. This only works within ec2. With this you can access quite a bit of information about the instance. However, tags do not appear to be included.
You should be able to take the instance id along with the correct authentication to get the instance tags. If you are going to run this on an instance, you may want to provide an IAM user with limited access instead of a user which has access to everything in case the instance is compromised.
While using user-data may be the simplest solution, the OP was asking specifically about the tagging, and unfortunately amazon hasn't made this as easy as it could be. However, It can be done. You want to use a combination of 2 amazon services.
First you need to retrieve the Instance ID. This can be achieved by hitting the URL from within your instance:
http://169.254.169.254/latest/meta-data/instance-id
Once you have the resource ID, you'll want to use Amazon's EC2 API to access the tags. Since you said you're using Java, I would suggest the Using the AWS SDK amazon makes available. Within this SDK you'll find a method called describeTags (documentation). You can use a Resource ID as one of the filters to get the specific tags to your instance. Supported filters are
tag key
resource-id
resource-type
I suggest doing this retrieval at boot using something like cloud-init and caching the tags on your server for use later if necessary.

How do I maintain session state with a Google Earth client?

I'm playing with dynamic updates to Google Earth KML files.
The updates are of the form
<kml...>
<NetworkLinkControl>
<Update>
<targetHref="...">
<Change>
<Placemark targetId="...">
...stuff to update...
</Placemark>
</Change>
</Update>
</NetworkLinkControl>
</kml>
And it all works greatm from my Java Servlet - except that GE doesn't seem to support HTTP Sessions, and I need to provide only the updates that have occurred since the last request from a given client.
Am I doing something wrong? Does GE support sessions and I'm too stupid to work out how? If I need to provide client-specific updates without sessions, how can I do that? (I know I could use the source IP address as a coarse measure but that feels kinda nasty...)
Thanks!
Old question, but you need to encode the session ID as part of the URLs. GE does not maintain cookies.
It seems that I can use the kml/NetworkLinkControl/cookie element to give the client a parameter to send back to me. Trying to use this to get the client to tell me when it last requested an update and use this instead of sessions...

Categories

Resources