% MJSWorker Worker in a MJS cluster
%
% parallel.cluster.MJSWorker properties:
% AllHostAddresses - IP addresses of the worker host
% Name - Name of the worker
% Parent - The cluster to which this worker belongs

% Copyright 2011-2020 The MathWorks, Inc.

classdef ( Sealed ) MJSWorker < parallel.Worker

properties ( SetAccess = immutable )
%AllHostAddresses IP addresses of the worker host
% AllHostAddresses indicates the IP addresses of the computer
% running the worker.
% (read-only)
%
% See also parallel.cluster.MJSWorker.Name
AllHostAddresses

%Name Name of the worker
% The descriptive name of a worker is set when its service is
% started, as described in "Customize Services" in the
% MATLAB Parallel Server System Administrator's
% Guide.
%
% See also parallel.cluster.MJSWorker.AllHostAddresses
Name
end

properties ( Transient, SetAccess = immutable )
%Parent The cluster to which this worker belongs
%
% See also parallel.cluster.MJS,
% parallel.cluster.MJSComputeCloud.
Parent
end

methods ( Hidden )
function hSetProperty( ~, ~, ~ )
assert( false );
end
function hSetPropertyNoCheck( ~, ~, ~ )
assert( false );
end
function v = hGetProperty( ~, names )
% No PCTGetSet properties
assert( iscell( names ) && isempty( names ) );
v = {};
end
function [workerPropertyMap, propNames] = hGetDisplayItems(obj, diFactory)
workerPropertyMap = hGetDisplayItems@parallel.Worker(obj, diFactory);

% The order the properties appear in the propNames array is the
% order in which they will be displayed.
propNames = {...
'Host', ...
'ComputerType', ...
'Separator', ...
'Name', ...
'AllHostAddresses'};

% Add MJSWorker specific displayable items to map
workerPropertyMap('Name') = diFactory.createDefaultItem(obj.hGetDisplayPropertiesNoError('Name'));
workerPropertyMap('AllHostAddresses') = diFactory.createDefaultItem(obj.hGetDisplayPropertiesNoError('AllHostAddresses'));
end

function obj = MJSWorker( mjs, hostName, computerMLType, allHostAddresses, name )
import parallel.internal.types.Variant
import parallel.internal.cluster.MJSMethods

validateattributes( mjs, ...
{'parallel.cluster.MJS', 'parallel.cluster.MJSCloudCluster'}, ...
{'scalar'} );

obj@parallel.Worker( hostName, computerMLType );
obj.Parent = mjs;
obj.AllHostAddresses = allHostAddresses;
obj.Name = name;
end

function hInvalidate( obj )
%hInvalidate Invalidate worker object without destroying underlying data.
delete( obj );
end
end

methods ( Access = private )
function delete( obj )
delete@handle( obj );
end
end
end
%#ok<*ATUNK> custom attributes