forked from elastic/ml-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.x][ML] Add timeouts to named pipe connections (elastic#1515)
This PR adds timeouts to the named pipe connections of the autodetect, normalize and data_frame_analyzer processes. (The controller process already had a different mechanism, tied to the ES JVM lifetime.) Before this change if the ES JVM didn't connect to one of the named pipes of an autodetect, normalize or data_frame_analyzer process then it would hang forever. After this change if nothing connects to the other end of a named pipe that the C++ process has created within the timeout period then it will delete the named pipe and exit. The timeout will be supplied on the command line by a followup Java PR. In the meantime, (unreleased snapshot) builds that have the C++ change but not the Java change will use a timeout of 5 minutes, which is better than nothing and highly unlikely to be less than the configured process connect timeout in the ES settings. Backport of elastic#1514
- Loading branch information
1 parent
e8a3967
commit 68feffd
Showing
31 changed files
with
643 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
#include "CBlockingCallCancellingStreamMonitor.h" | ||
|
||
#include <core/CLogger.h> | ||
|
||
#include <istream> | ||
|
||
namespace ml { | ||
namespace controller { | ||
|
||
CBlockingCallCancellingStreamMonitor::CBlockingCallCancellingStreamMonitor( | ||
core::CThread::TThreadId potentiallyBlockedThreadId, | ||
std::istream& monitorStream) | ||
: CBlockingCallCancellerThread{potentiallyBlockedThreadId}, m_MonitorStream{monitorStream} { | ||
} | ||
|
||
void CBlockingCallCancellingStreamMonitor::waitForCondition() { | ||
char c; | ||
while (m_MonitorStream >> c) { | ||
if (this->isShutdown()) { | ||
return; | ||
} | ||
} | ||
} | ||
|
||
void CBlockingCallCancellingStreamMonitor::stopWaitForCondition() { | ||
// This is to wake up the stream reading in the waitForCondition() method of | ||
// this object. If this has an effect then the assumption is that the | ||
// program is exiting due to a reason other than the stream this object is | ||
// monitoring ending. | ||
if (this->cancelBlockedIo() == false) { | ||
LOG_WARN(<< "Failed to cancel blocked IO in thread " << this->currentThreadId()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.