Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage -> Master #292

Merged
merged 14 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions +dj/+lib/getpass.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@
% wait for password entry
uiwait
pass = get(hpass,'userdata');
if isempty(pass)
pass = '';
end

% remove the figure to prevent passwork leakage
delete(hfig)


end

function keypress_cb(hObj, data, hpass)
% Callback function to handle actual key strokes

Expand All @@ -55,4 +60,5 @@ function keypress_cb(hObj, data, hpass)
pass = [pass data.Character];
end
set(hpass, 'userdata', pass)
set(hpass, 'String', char('*' * sign(pass)))
set(hpass, 'String', char('*' * sign(pass)))
end
7 changes: 5 additions & 2 deletions +dj/conn.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

% get password prompt option
if nargin < 7 || isempty(nogui)
nogui = false;
nogui = ~usejava('desktop');
end


Expand Down Expand Up @@ -117,4 +117,7 @@

if nargout==0
query(connObj, 'SELECT connection_id()')
end
end

end

42 changes: 36 additions & 6 deletions +dj/kill.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,64 @@
% of the attributes of information_schema.processlist: ID, USER, HOST,
% DB, COMMAND, TIME, STATE, INFO.
%
% dj.kill(restriction, connection) allows specifying the target connection.
% will use default connection (dj.conn) if not specified.
%
% dj.kill(restriction, connection, order_by) allows providing an order_by
% argument. By default, output is lited by ID in ascending order.
%
% Examples:
% dj.kill('HOST LIKE "%at-compute%"') lists only connections from
% at-compute.
%
% dj.kill('TIME > 600') lists only connections older than 10 minutes.
%
% dj.kill('', dj.conn, 'time') will display no restrictions for the
% default connection ordered by TIME.
%


function kill(restriction, connection, order_by)

if nargin < 3
order_by = {};
end

function kill(restriction)
if nargin < 2
connection = dj.conn;
end

qstr = 'SELECT * FROM information_schema.processlist WHERE id <> CONNECTION_ID()';

if nargin && ~isempty(restriction)
qstr = sprintf('%s AND (%s)', qstr, restriction);
end


if isempty(order_by)
qstr = sprintf('%s ORDER BY id', qstr);
else
if iscell(order_by)
qstr = sprintf('%s ORDER BY %s', qstr, strjoin(order_by, ','));
else
qstr = sprintf('%s ORDER BY %s', qstr, order_by);
end
end

while true
query(dj.conn, qstr)
query(connection, qstr)
id = input('process to kill (''q''-quit, ''a''-all) > ', 's');
if ischar(id) && strncmpi(id, 'q', 1)
break
elseif ischar(id) && strncmpi(id, 'a', 1)
res = query(dj.conn, qstr);
res = query(connection, qstr);
id = double(res.ID)';
for i = id
query(dj.conn, 'kill {Si}', i)
query(connection, 'kill {Si}', i)
end
break
end
id = sscanf(id,'%d');
if ~isempty(id)
query(dj.conn, 'kill {Si}', id(1))
query(connection, 'kill {Si}', id(1))
end
end
14 changes: 14 additions & 0 deletions docs-parts/computation/06-distributed-computing_kill_order_by.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

For example, to sort the output by hostname in descending order:

.. code-block:: matlab


dj.kill('', dj.conn, 'host desc');

ID USER HOST DB COMMAND TIME STATE INFO TIME_MS ROWS_SENT ROWS_EXAMINED
+--+ +----+ +---------+ +--+ +-------+ +----+ +-----+ +----+ +-------+ +---------+ +-------------+
35 cat localhost:38772 Sleep 94 94040 0 0
36 cat localhost:36543 Sleep 68 68421 1 0

process to kill ('q'-quit, 'a'-all) > q