heartbeat interview questions
Top heartbeat frequently asked interview questions
I am trying to measure Heart Beat using the camera in android device.
As far as i see,
Placing your finger tip on the camera lens and watching the changes in frames in camera.
I have tried the application here but it does not seem to be correct.
Source: (StackOverflow)
ZooKeeper is a highly available coordination service for data centers. It originated in the Hadoop project. One can implement locking, fail over, leader election, group membership and other coordination issues on top of it.
Are there any alternatives to ZooKeeper? (free software of course)
Source: (StackOverflow)
My question is very simple and straight forward. Is there any technique through which i can calculate the heartbeat of a person using android device.
I googled it and found some results in which they implemented it using camera.
Any other idea or help will be highly appreciated.
Thanks.
Source: (StackOverflow)
This exact code doesn't work, but, I was hoping something like it was:
io.sockets.on('connection', function(socket) {
socket.on('heartbeat', function() {
// Do something here...
});
});
Is something like this possible? I mean, I know I can just make a different function that triggers every, say, 15 seconds using a setInterval:
io.sockets.on('connection', function(socket) {
setInterval(function() {
// Do something
},15000);
});
But since the heartbeat is already running at this interval, why not make use of it?
In any case, any insight would be greatly appreciated.
Source: (StackOverflow)
I'm looking at implementing a "Heartbeat" process to do a lot of repeated cleanup tasks throughout the day.
This seemed like a good chance to use the Command pattern, so I have an interface that looks like:
public interface ICommand
{
void Execute();
bool IsReady();
}
I've then created several tasks that I want to be run. Here is a basic example:
public class ProcessFilesCommand : ICommand
{
private int secondsDelay;
private DateTime? lastRunTime;
public ProcessFilesCommand(int secondsDelay)
{
this.secondsDelay = secondsDelay;
}
public void Execute()
{
Console.WriteLine("Processing Pending Files...");
Thread.Sleep(5000); // Simulate long running task
lastRunTime = DateTime.Now;
}
public bool IsReady()
{
if (lastRunTime == null) return true;
TimeSpan timeSinceLastRun = DateTime.Now.Subtract(lastRunTime.Value);
return (timeSinceLastRun.TotalSeconds > secondsDelay);
}
}
Finally, my console application runs in this loop looking for waiting tasks to add to the ThreadPool:
class Program
{
static void Main(string[] args)
{
bool running = true;
Queue<ICommand> taskList = new Queue<ICommand>();
taskList.Enqueue(new ProcessFilesCommand(60)); // 1 minute interval
taskList.Enqueue(new DeleteOrphanedFilesCommand(300)); // 5 minute interval
while (running)
{
ICommand currentTask = taskList.Dequeue();
if (currentTask.IsReady())
{
ThreadPool.QueueUserWorkItem(t => currentTask.Execute());
}
taskList.Enqueue(currentTask);
Thread.Sleep(100);
}
}
}
I don't have much experience with multi-threading beyond some work I did in Operating Systems class. However, as far as I can tell none of my threads are accessing any shared state so they should be fine.
Does this seem like an "OK" design for what I want to do? Is there anything you would change?
Source: (StackOverflow)
Hey gang. I have just written a client and server in C++ using sys/socket. I need to handle a situation where the client is still active but the server is down. One suggested way to do this is to use a heartbeat to periodically assert connectivity. And if there is none to try to reconnect every X seconds for Y period of time, and then to time out.
Is this "heartbeat" the best way to check for connectivity?
The socket I am using might have information on it, is there a way to check that there is a connection without messing with the buffer?
Source: (StackOverflow)
I have never heard of the heartbeat until the heartbleed bug. I wonder what is the difference between this and a ping, and if there are other signals to manage the connection (also, which are not data packages).
Source: (StackOverflow)
I'm trying to access the heart rate monitor of a Samsung Gear Live watch. The watch is paired with a 4.4.4 handset and works correctly. I'm following the official BasicSensorsApi sample.
I can successfully connect to Google Play Services with the following scope:
addScope(new Scope(Scopes.FITNESS_LOCATION_READ_WRITE))
.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
.addScope(new Scope(Scopes.FITNESS_BODY_READ_WRITE))
But then, when I want to list all available heart rate monitors, I receive an empty list of DataSource
:
private void findFitnessDataSources() {
Fitness.SensorsApi.findDataSources(mGoogleApiClient, new DataSourcesRequest.Builder()
.setDataTypes(
DataType.TYPE_HEART_RATE_BPM)// At least one datatype must be specified.
.setDataSourceTypes(
DataSource.TYPE_RAW)// Specify whether data type is raw or derived.
.build())
.setResultCallback(new ResultCallback<DataSourcesResult>() {
@Override
public void onResult(DataSourcesResult dataSourcesResult) {
for (DataSource dataSource : dataSourcesResult.getDataSources()) {
if (dataSource.getDataType().equals(DataType.TYPE_HEART_RATE_BPM)
&& mListener == null) {
registerFitnessDataListener(dataSource,
DataType.TYPE_HEART_RATE_BPM);
}
}
}
});
If I change the DataType
to, for example, TYPE_STEP_COUNT_CUMULATIVE
or TYPE_LOCATION_SAMPLE
, the list will contain my phone, which seems logical.
Why is the watch not listed as an available DataSource
then?
Please note:
This is not a duplicate of:
- Get Heart Rate from “Sensor” Samsung Gear Live
- How to access heart rate sensor in Android Wearable?
because I want to access the heart beat data through the recently released Google Fit API.
I don't think enabling debug mode on the watch is necessary, but I've tried that. Also, I don't think adding BODY_SENSORS
permission is necessary, because the whole process is managed by Google Fit API anyway, but I've tried that too with no luck.
Source: (StackOverflow)
I have a bug in my app that seems to show it's face only when I pause the app in the debugger for a few minutes. I suspect this is due to a third party networking library I am using having a heartbeat thread, which becomes disconnected when it can not ping the server while it's heartbeat thread is paused.
I am trying to write a test case app for this to verify that this is the cause of the bug. To do so, I need a way to pause all the threads in the app (which i will later narrow down to pausing only the thread I suspect may be the heartbeat thread) to simulate pausing the app in the debugger.
Does anyone know how to do this? Is it even possible for one thread to cause another to sleep?
Thanks,
Alex
UPDATE:
I ended up deciding that I didn't really need an app to do this for me, seeing as the point was just to verify that pausing in the debugger was causing the disconnect. So, here's what I did... (The simplest ways are often the best... or at least the simplest...)
private static void Main(string[] args)
{
IPubSubAdapter adapter = BuildAdapter();
bool waitingForMessage;
adapter.Subscribe(_topic, message => waitingForMessage = false, DestinationType.Topic);
Stopwatch timePaused = new Stopwatch();
while (adapter.IsConnected)
{
Console.WriteLine("Adapter is still connected");
waitingForMessage = true;
adapter.Publish(_topic, "testmessage", DestinationType.Topic);
while (waitingForMessage)
{
Thread.Sleep(100);
}
timePaused.Reset();
timePaused.Start();
Debugger.Break();
timePaused.Stop();
Console.WriteLine("Paused for " + timePaused.ElapsedMilliseconds + "ms.");
Thread.Sleep(5000); // Give it a chance to realise it's disconnected.
}
Console.WriteLine("Adapter is disconnected!");
Console.ReadLine();
}
And the output:
Adapter is still connected
Paused for 10725ms.
Adapter is still connected
Paused for 13298ms.
Adapter is still connected
Paused for 32005ms.
Adapter is still connected
Paused for 59268ms.
Adapter is disconnected!
Source: (StackOverflow)
The title pretty much sums it up. I have a zotonic site running with -heart, it uses lots of cpu time and I can't get an erlang shell. So, is there a way to kill the vm? killall heart
and killall beam.smp
are not working.
I found this question:
Stop Erlang Daemon
, but it does not really answer my question.
Source: (StackOverflow)
Can you help me understand Linux HA?
- Pacemaker, Heartbeat, Corosync seem to be part of a whole HA stack, but how do they fit together?
- How does wackamole differ from Pacemaker/Heartbeat/Corosync? I've seen opinions that wackamole is better than Heartbeat because it's peer-based. Is that valid?
- The last release of wackamole was 2.5 years ago. Is it still being maintained or active?
- What would you recommend for HA setup for web/application/database servers?
Source: (StackOverflow)
https://tools.ietf.org/html/rfc6520 does not explain why a heartbeat request/response round-trip is supposed to contain a payload. It just specifies that there is room for payload and that the response has to contain the same payload as the request.
What is this payload good for? My questions are:
What could it be that the engineers thought when they designed the protocol to allow for including arbitrary payload into the heartbeat request? What are the advantages?
What are the reasons that this payload must be contained in the response?
I see that by allowing for arbitrary payload the application is able to unambiguously match a certain response with a certain request. Is that the only advantage? If yes, then why did one not force the payload to be of a certain length? What is the flexibility in the payload length good for? Does it have to do with a cryptographic concept, such that the length of heartbeat requests must be unpredictable?
Other "heartbeat"-like protocol extensions simply pre-define the exact request (e.g. "ping") and the corresponding response (e.g. "pong"). Why did https://tools.ietf.org/html/rfc6520 take a different route?
It is important to understand the reasoning behind the choices made in RFC6520 in order to properly assess hypotheses that all this might have been an intelligently placed backdoor.
Source: (StackOverflow)
I'm doing a final year project at university which involves making a medical application for Android, as a practice I have to make a heart rate monitor app.
I have worked out that the best way to do this is to look for colour changes in your blood when holding the camera against your finger with the flash switched on.
This is where the problems come into play, is it possible to take a photo every 66 milliseconds on the camera, then compare each pair of photos for any intensity changes in order to count a heart beat? or am I better off recording a video and analysing each frame looking for a change.
Heck is it even possible to just look at the video preview and compare each frame.
The questions I need answering for this problem are neatly listed below
What is the best method for this, taking photos, recording video or looking at the live preview.
Is there any posts or pages I can visit on the internet where people have attempted similar things
Anyone got a basic method I should do to get two images that I can compare within the time frame.
Lastly If I do take the basic take a picture every 66 milliseconds approach, what can I do to ensure the picture is taken at the correct time intervals
Source: (StackOverflow)
I'm trying to set up a node.js server, using socket.io. The problem I'm seeing is that my server is disconnecting+reconnecting the client every 25 seconds.
Here's my server code:
var io = require('socket.io').listen(5876);
io.sockets.on('connection', function (socket)
{
console.log("New connection established");
socket.on('disconnect', function()
{
console.log("A client has disconnected.");
});
}
My client connects using the socket.io.js distribution. As I understand it (apparently incorrectly), I need my client to send a "heartbeat" (a message of "::2") every 15 seconds to prevent the server from thinking the connection is dead and disconnecting it. Basically:
<script src="socket.io.js"></script>
<script>
var socket = io.connect('http://localhost:5876');
socket.on('connect', function(data)
{
console.log("Connected to server.");
setInterval(function() { socket.emit("::2"); console.log("sent heartbeat"); }, 15000); // schedule a heartbeat for every 15 seconds
});
</script>
But the client is still getting disconnected+reconnected every 25 seconds (excluding the very first 25th-second-tick).
The node.js server console log looks like this (may have cut out some earlier identical connect/disconnect phases, as it was echoing every 25 seconds):
New connection established
debug - emitting heartbeat for client 652791160849839915
debug - websocket writing 2::
debug - set heartbeat timeout for client 652791160849839915
debug - got heartbeat packet
debug - cleared heartbeat timeout for client 652791160849839915
debug - set heartbeat interval for client 652791160849839915
info - transport end
debug - set close timeout for client 652791160849839915
debug - cleared close timeout for client 652791160849839915
debug - cleared heartbeat interval for client 652791160849839915
A client has disconnected.
debug - discarding transport
debug - client authorized
info - handshake authorized 5961067041159055274
debug - setting request GET /socket.io/1/websocket/5961067041159055274
debug - set heartbeat interval for client 5961067041159055274
debug - client authorized for
debug - websocket writing 1::
New connection established
How can I stop my server from disconnecting+reconnecting the client every 25 seconds?
Source: (StackOverflow)
I wish to make an AJAX call using jQuery as a "heartbeat" in the background so that my web application can check for new data. For example every 10 seconds.
I have seen on other posts that it is possible to use setInterval()
to call a method which does the call every X number of milliseconds.
However, what happens if my AJAX call takes more than 10 seconds? I still want it to complete the last request and I don't want another call to be instigated when there is already one in progress. This could result in the same information being placed on to the page twice!
What is the way to implement this for my method to wait for the original AJAX call to be completed, rather than simply "every 10 seconds", when the original one may not already be complete.
Source: (StackOverflow)