Apache Flink: Periodically load configuration for a function - apache-flink

Let's say, There is dynamic configuration are stored in a DB to filter blacklisted events from the stream.
A filter function uses this configuration and needs to reload/refresh a new configuration after a time interval(10 min).
A function can be called in every window call to reload the config and reassign the config variable.
NOTE: As this function call in a window is independent of stream's events data so don't want to buffer/hold the stream events in memory till the window is triggered.
Any leads?

You could put a ProcessFunction in front of the window, and have it do the filtering. I'm suggesting a ProcessFunction because it can have a timer that fires every 10 minutes to trigger the reload/refresh of the configuration data.
In this way, all of the events that reach the window will have been pre-filtered by the version of the droplist configuration that was active at the time each event was received.
You could take further advantage of streaming, and stream in the changes to the droplist configuration as they occur, rather than polling for them every 10 minutes.

Related

I want to show real time data fetched by the REST api on the Frontend of the application

I have a list of transactions that are generated in seconds, I am using a wrapper to get these transactions so I made a rest api to get the transactions according to the no. But in the mean time the transaction will get generated more so how do I show the recent on as they generate continuously .
I want to create a Block Explorer on the private Ethereum blockchain using node.js as backend and angular.js as frontend.
You could use here Websockets.
For example Socket.io - https://github.com/socketio/socket.io
Here is Socket.io compoenent for Angular: https://github.com/btford/angular-socket-io
So when your transactions are generated, you will send Push message to client, and client will update it's transaction list.
Possibly the most common approach here, id you have control of contract mods, is to include event emitters for every important state change. This exposes your contract transactions in a detailed (even indexable) and inexpensive way.
On the client, you can use event watchers. This are easily configured with AngularJS. When events arrive, they invoke callbacks. You can do what you need to support the UI or offchain storage in the callback.
For example, you can append a row to an array in to Angular's view model. Angular does a good jub of updating the view when the data in the model as changed. So, a live updated display of transaction events as they arrive is quite feasible and not especially difficult.
Hope it helps.

How to Force Button Action Immediately

So I'm not sure if there is truly a way to make this happen.
Basically I have an angular app with a nodejs backend that shows longrunning queries on our production environment. This is set on an interval to refresh this info every 20 seconds. The issue is this:
Buttons on the page, if clicked when a refresh is occurring, will not fire off. They have to wait until the whole stream of calls to refresh the data have finished, and even then sometimes, they do not fire.
If I happen to catch it while no refresh is occurring, the button works as expected.
Is there a way to force this action to take precedence over the refresh so it occurs immediately even if there are other processes occurring?
Thanks!
Based on your clarification in your comments, it sounds like you're hitting your browser's limit on how many connections can be made to any given hostname. Look at the Connections per Hostname column here.
To fix this, send less calls at once. For example, you could implement your own queuing system for your refresh-related calls, instead of firing them off all at once, leaving plenty of connections open for other requests (like your button).

how to change apache camel timer polling period dynamically

Hi I am using apache camel timer component in my route. I need to change the period polling interval dynamically. I have a business method which will return some time interval and it will be different depending on logic. I have to pass this to Timer so that my timer should poll according to this interval. I don't want to start and stop the route with new interval as its performance hit.
I want one timer route for which period has to be set dynamically.
The timer cannot be changed at runtime, as its using the JDK java.util.Timer which cannot be changed.
You can use camel-quartz which allows changing the scheduler at runtime, which you can do using JMX. There is also a Quartz plugin in hawtio - http://hawt.io/plugins/quartz/ - that allows you to change the scheduler using a web UI.

Page does not self refresh after task in Taskqueue is done updating values

So I had a problem with a task in a worker's POST command taking way too long and was getting DeadlineExceededErrors. I started using Taskqueues and that part works great now- no more Deadline errors. The problem now is that my main page "refreshes" (self.redirect) before the task queue is done so the new detail is not shown automatically and the user has to press refresh themselves, which is a hassle. Do you have any recommendations as to the easiest way to fix this problem? A high level overview of my app is as follows:
1) Main Handler has Get and Post - Get writes a html page which shows new values after the task in the queue has completed. It also has a form which submits queries to its Post section.
The Post section adds the task onto the taskqueue and then calls self.redirect back to the main html page.
2) The Main Worker has a Post command - this is what is added into the queue. It takes about 1-2 minutes to run and then updates a ndb.Model element with new values.
Back in the Main Handler Get function the ndb.Model element has its .query() function called to return the new values.
Any help or advice would be appreciated. Thanks!
A task that takes 1-2 minutes to execute is not suitable for user interaction: users are not used to wait that long. Typically, there are three options to resolve this:
(a) Offer a refresh button.
(b) Start a timer that periodically checks if a task is complete. This timer updates the page when a task is finished and stops. Remember that a user may leave the page which started the task.
(c) Deliver the result of a task in a different way (email or push notification).
If your user is willing to wait that long, you could serve these requests in a custom module, which does not have the time limitation. See Modules in GAE docs.

How can I refresh a window based on the message sent by an observer subject?

I implemented the observer design pattern in my application, but my app sends to an remote server requests via http protocol that take some time to resolve.
So, naturally, I did the sending an receiving part in a separate thread.
Can you please tell me how to make an window that observes the RequestObject to modify it's state based on the state of the request?
In the debugger step by step mode the window runes the code that I want it to do, but the window never refreshes its self.
Since I don't have a sample of your code I don't know the exacts of how you are updating your UI. If you are attempting to update the UI in the seperate thread that could be your issue. This may be of some help. http://msdn.microsoft.com/en-us/magazine/cc188732.aspx
You may also consider using the Task Parellel Library to perform your asyc operations.
http://msdn.microsoft.com/en-us/library/dd997423.aspx

Resources