main content

connect to schedulers when client utilities are not available locally -凯发k8网页登录

connect to schedulers when client utilities are not available locally

constructor

r = parallel.cluster.remoteclusteraccess(username)

r = parallel.cluster.remoteclusteraccess(username,p1,v1,...,pn,vn)

description

r = parallel.cluster.remoteclusteraccess(username) creates a remoteclusteraccess object with the username set to username.

by default, you are prompted for a password when you connect to the cluster.

tip

if you have set up a cluster profile for a remote cluster, use . for more information, see discover clusters and use cluster profiles.

you only need to use remoteclusteraccess if you need to modify plugin scripts for third-party schedulers that you connect to in nonshared or remote submission mode. you use plugin scripts when you connect to a cluster using the generic scheduler interface.

if the client is not able to submit directly to the third-party scheduler, or the client does not share a file system with the cluster, consider the following:

  • if the third-party scheduler has a mathworks® add-on, install it. when you use an add-on, you can set up your cluster profile using the set-up wizard or the cluster profile manager to set many settings. for more information, see .

  • if you need to use a third-party scheduler that does not have an add-on, or if you need to customize an add-on, see (matlab parallel server).

  • use remoteclusteraccess when you need to modify settings for remote cluster connection, submission, or data transfer.

r = parallel.cluster.remoteclusteraccess(___,name,value) creates a remoteclusteraccess object using one or more name-value arguments. for example, specify 'port',31415 to connect to a cluster using port number 31415. specify name-value arguments after all other input arguments.

the accepted name-value arguments are:

  • 'authenticationmode' — authentication mode you use when you connect to the cluster, specified as a string scalar, character vector, string array or cell array.

    if you specify the argument 'identityfilename', the default value is 'identityfile'. otherwise, the default value is 'password'. valid values for 'authenticationmode' are:

    • 'agent' – the client interfaces with an ssh agent running on the client machine.

    • 'identityfile' – the client uses an identity file to authenticate when you connect to the cluster. if you specify a file using the identityfilename option, you use that file. otherwise, matlab® prompts you to specify the full path to an identity file when you connect.

    • 'multifactor' – the client prompts you for input one or more times. for example, if two-factor authentication (2fa) is enabled on the client, the client requests your password and a response for the second authentication factor.

    • 'password' – the client prompts you for your ssh password. your user name is specified by the username property.

    alternatively, to connect to a client with multiple authentication requirements, specify authenticationmode as a string array or cell array containing a combination of 'agent', 'identityfile', 'multifactor' and 'password'.

  • 'identityfilehaspassphrase' — flag indicating if the identity file requires a passphrase, specified as true or false. if true, you are prompted for a password when you connect. if an identity file is not supplied, this name-value argument is not used.

  • 'identityfilename' — full path to the identity file to use when remoteclusteraccess connects to a remote host, specified as 'identityfilename' and a string scalar or character vector.

  • 'port' — port number on the cluster you connect to, specified as an integer scalar between 1 and 65535.

    the default value is 22.

for more information and detailed examples, see and .

methods

method namedescription
connect

connect(r,clusterhost) establishes a connection to the specified host using the user credential options supplied in the constructor. file mirroring is not supported. clusterhost must run linux.

connect(r,clusterhost,remotedatalocation) establishes a connection to the specified host using the user credential options supplied in the constructor. remotedatalocation identifies a folder on the clusterhost that is used for file mirroring. the user credentials supplied in the constructor must have write access to this folder.

disconnectdisconnect(r) disconnects the existing remote connection. the connect method must have already been called.
dolastmirrorforjob

dolastmirrorforjob(r,job) performs a final copy of changed files from the remote remotedatalocation to the local jobstoragelocation for the supplied job. any running mirrors for the job also stop and the job files are removed from the remote remotedatalocation. the startmirrorforjob or resumemirrorforjob method must have already been called.

getremotejoblocation

getremotejoblocation(r,jobid,remoteos) returns the full path to the remote job location for the supplied jobid. valid values for remoteos are 'pc' and 'unix'.

isjobusingconnection

isjobusingconnection(r,jobid) returns true if the job is currently being mirrored.

resumemirrorforjob

resumemirrorforjob(r,job) resumes the mirroring of files from the remote remotedatalocation to the local jobstoragelocation for the supplied job. this is similar to the startmirrorforjob method, but does not first copy the files from the local jobstoragelocation to the remote remotedatalocation. the connect method must have already been called. this is useful if the original client matlab session has ended, and you are accessing the same files from a new client session.

runcommand

[status,result] = runcommand(r,command) runs the supplied command on the remote host and returns the resulting status and standard output. the connect method must have already been called.

startmirrorforjob

startmirrorforjob(r,job) copies all the job files from the local jobstoragelocation to the remote remotedatalocation, and starts mirroring files so that any changes to the files in the remote remotedatalocation are copied back to the local jobstoragelocation. the connect method must have already been called.

stopmirrorforjob

stopmirrorforjob(r,job) immediately stops the mirroring of files from the remote remotedatalocation to the local jobstoragelocation for the specified job. the startmirrorforjob or resumemirrorforjob method must have already been called. this cancels the running mirror and removes the files for the job from the remote location. this is similar to dolastmirrorforjob, except that stopmirrorforjob makes no attempt to ensure that the local job files are up to date. for normal mirror stoppage, use dolastmirrorforjob.

getconnectedaccess

getconnectedaccess(host,username) returns a remoteclusteraccess object that is connected to the supplied host. this function may return a previously constructed remoteclusteraccess object if one exists. host must run linux.

getconnectedaccess(...,p1,v1,...pn,vn) passes the additional parameters to the remoteclusteraccess constructor.

getconnectedaccesswithmirror

getconnectedaccesswithmirror(host,remotedatalocation,username) returns a remoteclusteraccess object that is connected to the supplied host, using remotedatalocation as the mirror location. this function may return a previously constructed remoteclusteraccess object if one exists. host must run linux.

getconnectedaccesswithmirror(...,p1,v1,...pn,vn) passes the additional parameters to the remoteclusteraccess constructor.

properties

a remoteclusteraccess object has the following read-only properties. their values are set when you construct the object or call its connect method.

property namedescription
authenticationmode

option indicating how you are authenticated when you connect to the cluster, returned as one of the following:

  • 'agent' – the client interfaces with an ssh agent running on the client machine.

  • 'identityfile' – the client uses an identity file to authenticate when you connect to the cluster. if the identityfilename property is not an empty string or empty character vector, you use that file. otherwise, matlab prompts you to specify the full path to an identity file when you connect.

  • "multifactor" – the client prompts you for input one or more times. for example, if two-factor authentication (2fa) is enabled on the client, the client requests your password and a response for the second authentication factor.

  • 'password' – the client prompts you for your ssh password. your user name is specified by the username property.

  • array containing a combination of 'agent', 'identityfile', 'multifactor' and 'password' - the client uses multiple authentication options to authenticate when you connect to the cluster.

if the identityfilename property is not an empty string scalar or empty character vector, this property is set to 'identityfile' by default. otherwise, it is set to 'password' by default.

to set this property, specify the 'authenticationmode' name-value argument when you create a remoteclusteraccess object.

hostname

name of the remote host to access, returned as a character vector.

the default value is an empty character vector.

identityfilehaspassphrase

flag indicating if the identity file requires a passphrase, specified as the comma-separated pair consisting of 'identityfilehaspassphrase' and true or false.

the default value is false.

if this property is set to true, you are prompted for a password when you connect. if an identity file is not supplied, this property is not used.

to set this property, specify the 'identityfilehaspassphrase' name-value argument when you create a remoteclusteraccess object.

identityfilename

full path to the identity file to use when the remoteclusteraccess object connects to a remote host, returned as a character vector.

the default value is an empty character vector. if this property is empty, you are prompted for a password when you connect.

to set this property, specify the 'identityfilename' name-value argument when you create a remoteclusteraccess object.

isconnected

flag indicating if the remoteclusteraccess object is connected to the cluster, returned as true or false.

the default value is false.

isfilemirrorsupported

flag indicating if file mirroring is supported for the remoteclusteraccess object, specified as true or false.

the default value is false.

the isfilemirrorsupported property is set to true if the jobstoragelocation property is not empty.

jobstoragelocation

location on the remote host for files that are being mirrored, returned as a character vector.

the default value is an empty character vector.

to set this property, use any of the following syntaxes to connect to the cluster:

  • connect(r,clusterhost,remotedatalocation)

  • r = getconnectedaccesswithmirror(host,remotedatalocation,username)

  • r = getconnectedaccesswithmirror(___,p1,v1,...pn,vn)

port

port number you use to connect to the cluster, returned as an integer scalar between 1 and 65535.

the default value is 22.

to set this property, specify the 'port' name-value argument when you create a remoteclusteraccess object.

useidentityfile

flag indicating if the remoteclusteraccessobject uses an identity file to connect to the cluster, returned as true or false.

the default value is false. if the authenticationmode property is 'identityfile', the useidentityfile property is true.

username

user name you use to connect to the cluster, returned as a character vector.

examples

mirror files from the remote data location. assume the object job represents a job on your generic scheduler.

remoteconnection = parallel.cluster.remoteclusteraccess('testname');
connect(remoteconnection,'headnode1','/tmp/filemirror');
startmirrorforjob(remoteconnection,job);
submit(job)
% wait for the job to finish
wait(job);
% ensure that all the local files are up to date, and remove the 
% remote files
dolastmirrorforjob(remoteconnection,job);
% get the output arguments for the job
results = fetchoutputs(job)

for more information and examples, see and .

version history

introduced in r2011a

see also

topics

    网站地图