org.kde.koala

Class Scheduler

public class Scheduler extends QObject implements DCOPObjectInterface

The KIO.Scheduler manages io-slaves for the application. It also queues jobs and assigns the job to a slave when one becomes available. There are 3 possible ways for a job to get a slave:

1. Direct

This is the default. When you create a job the KIO.Scheduler will be notified and will find either an existing slave that is idle or it will create a new slave for the job. Example:
    TransferJob job = KIO.get(KURL("http://www.kde.org"));
 

2. Scheduled

If you create a lot of jobs, you might want not want to have a slave for each job. If you schedule a job, a maximum number of slaves will be created. When more jobs arrive, they will be queued. When a slave is finished with a job, it will be assigned a job from the queue. Example:
    TransferJob job = KIO.get(KURL("http://www.kde.org"));
    KIO.Scheduler.scheduleJob(job);
 

3. Connection Oriented

For some operations it is important that multiple jobs use the same connection. This can only be ensured if all these jobs use the same slave. You can ask the scheduler to open a slave for connection oriented operations. You can then use the scheduler to assign jobs to this slave. The jobs will be queued and the slave will handle these jobs one after the other. Example:
    Slave slave = KIO.Scheduler.getConnectedSlave(
            KURL("pop3://bastian:password@mail.kde.org"));
    TransferJob job1 = KIO.get(
            KURL("pop3://bastian:password@mail.kde.org/msg1"));
    KIO.Scheduler.assignJobToSlave(slave, job1);
    TransferJob job2 = KIO.get(
            KURL("pop3://bastian:password@mail.kde.org/msg2"));
    KIO.Scheduler.assignJobToSlave(slave, job2);
    TransferJob job3 = KIO.get(
            KURL("pop3://bastian:password@mail.kde.org/msg3"));
    KIO.Scheduler.assignJobToSlave(slave, job3);
    // ... Wait for jobs to finish...
    KIO.Scheduler.disconnectSlave(slave);
 
Note that you need to explicitly disconnect the slave when the connection goes down, so your error handler should contain:
    if (error == KIO.ERR_CONNECTION_BROKEN)
        KIO.Scheduler.disconnectSlave(slave);
 
See SchedulerSignals for signals emitted by Scheduler

See Also: Slave Job

UNKNOWN: The KIO.Scheduler manages io-slaves for the application.

Constructor Summary
protected Scheduler(Class dummy)
Scheduler()
Method Summary
static booleanassignJobToSlave(Slave slave, SimpleJob job)
DCOPClientcallingDcopClient()
Returns the DCOPClient responsible for making the call.
static voidcancelJob(SimpleJob job)
Stop the execution of a job.
static voidcheckSlaveOnHold(boolean b)
When true, the next job will check whether KLauncher has a slave on hold that is suitable for the job.
StringclassName()
booleanconnect(QObject sender, String signal, String member)
static booleanconnect(String signal, QObject receiver, String member)
Function to connect signals emitted by the scheduler.
static booleanconnect(QObject sender, String signal, QObject receiver, String member)
booleanconnectDCOPSignal(String sender, String senderObj, String signal, String slot, boolean Volatile)
Connects to a DCOP signal.
voiddebug_info()
static booleandisconnect(QObject sender, String signal, QObject receiver, String member)
booleandisconnectDCOPSignal(String sender, String senderObj, String signal, String slot)
Disconnects a DCOP signal.
static booleandisconnectSlave(Slave slave)
static voiddoJob(SimpleJob job)
Register job with the scheduler.
voidemitDCOPSignal(String signal, byte[] data)
Emit signal as DCOP signal from this object with data as arguments
static DCOPObjectInterfacefind(String objId)
Try to find a dcop object with the given id.
ArrayListfunctions()
ArrayListfunctionsDynamic()
This function is of interest when you used an IDL compiler to generate the implementation for functions() but you still want to list some functions dynamically.
static SlavegetConnectedSlave(KURL url)
Requests a slave for use in connection-oriented mode.
static booleanhasObject(String objId)
Checks whether an object with the given id is known in this process.
ArrayListinterfaces()
Returns the names of the interfaces, specific ones last.
ArrayListinterfacesDynamic()
This function is of interest when you used an IDL compiler to generate the implementation for interfaces() but you still want to list some interfaces dynamically.
static voidjobFinished(SimpleJob job, Slave slave)
Called when a job is done.
QMetaObjectmetaObject()
static StringobjectName(QObject arg1)
Creates an object id for the QObject obj. This is done using the QObject.name() function.
StringobjId()
Returns the object id of the DCOPObject.
booleanprocess(String fun, byte[] data, StringBuffer replyType, byte[] replyData)
booleanprocessDynamic(String fun, byte[] data, StringBuffer replyType, byte[] replyData)
This function is of interest when you used an IDL compiler to generate the implementation for process() but you still want to dispatch some functions dynamically.
static voidpublishSlaveOnHold()
Send the slave that was put on hold back to KLauncher.
static voidputSlaveOnHold(SimpleJob job, KURL url)
Puts a slave on notice.
static voidregisterWindow(QWidget wid)
Send the slave that was put on hold back to KLauncher.
static voidremoveSlaveOnHold()
Removes any slave that might have been put on hold.
static voidscheduleJob(SimpleJob job)
Calling ths function makes that job gets scheduled for later execution, if multiple jobs are registered it might wait for other jobs to finish.
voidsetCallingDcopClient(DCOPClient arg1)
booleansetObjId(String objId)
Renames a dcop object, if no other with the same name exists Use with care, all dcop signals are disconnected
protected voidsetupSlave(Slave slave, KURL url, String protocol, String proxy, boolean newSlave)
protected voidslotCleanIdleSlaves()
protected voidslotScheduleCoSlave()
protected voidslotSlaveConnected()
voidslotSlaveDied(Slave slave)
protected voidslotSlaveError(int error, String errorMsg)
voidslotSlaveStatus(int pid, String protocol, String host, boolean connected)
protected voidslotUnregisterWindow(QObject arg1)
protected booleanstartJobDirect()
protected voidstartStep()
static voidunregisterWindow(QObject wid)
Unregisters the window registered by registerWindow().

Constructor Detail

Scheduler

protected Scheduler(Class dummy)

Scheduler

public Scheduler()

Method Detail

assignJobToSlave

public static boolean assignJobToSlave(Slave slave, SimpleJob job)

callingDcopClient

public DCOPClient callingDcopClient()
Returns the DCOPClient responsible for making the call. Only call this function while you are handling a DCOP call.

Returns: the DCOPClient responsible for making the call. This information is only guaranteed to be correct when entering your DCOP function.

UNKNOWN: Returns the DCOPClient responsible for making the call.

cancelJob

public static void cancelJob(SimpleJob job)
Stop the execution of a job.

Parameters: job the job to cancel

UNKNOWN: Stop the execution of a job.

checkSlaveOnHold

public static void checkSlaveOnHold(boolean b)
When true, the next job will check whether KLauncher has a slave on hold that is suitable for the job.

Parameters: b true when KLauncher has a job on hold

UNKNOWN: When true, the next job will check whether KLauncher has a slave on hold that is suitable for the job.

className

public String className()

connect

public boolean connect(QObject sender, String signal, String member)

connect

public static boolean connect(String signal, QObject receiver, String member)
Function to connect signals emitted by the scheduler.

See Also: Scheduler Scheduler

UNKNOWN: Function to connect signals emitted by the scheduler.

connect

public static boolean connect(QObject sender, String signal, QObject receiver, String member)

connectDCOPSignal

public boolean connectDCOPSignal(String sender, String senderObj, String signal, String slot, boolean Volatile)
Connects to a DCOP signal.

Parameters: sender the name of the client that emits the signal. When empty the signal will be passed from any client. senderObj the name of the sending object that emits the signal. signal the name of the signal. The arguments should match with slot. slot The name of the slot to call. Its arguments should match with signal. Volatile If true, the connection will not be reestablished when sender unregisters and reregisters with DCOP. In this case the sender must be registered when the connection is made. If false, the connection will be reestablished when sender reregisters. In this case the connection can be made even if sender is not registered at that time.

  • Volatile is true and sender does not exist.
  • signal and slot do not have matching arguments.
  • @return false if a connection could not be established. This will be the case when

    UNKNOWN: Connects to a DCOP signal.

    debug_info

    public void debug_info()

    disconnect

    public static boolean disconnect(QObject sender, String signal, QObject receiver, String member)

    disconnectDCOPSignal

    public boolean disconnectDCOPSignal(String sender, String senderObj, String signal, String slot)
    Disconnects a DCOP signal. A special case is when both sender & signal are empty. In this case all connections related to this object in the current client are disconnected. (Both connections from as well as to this object!)

    Parameters: sender the name of the client that emits the signal. senderObj the name of the object that emits the signal. If empty all objects will be disconnected. signal the name of the signal. The arguments should match with slot. If empty all objects will be disconnected. slot The name of the slot the signal is connected to. If empty all slots will be disconnected.

    Returns: false if no connection(s) where removed.

    UNKNOWN: Disconnects a DCOP signal.

    disconnectSlave

    public static boolean disconnectSlave(Slave slave)

    doJob

    public static void doJob(SimpleJob job)
    Register job with the scheduler. The default is to create a new slave for the job if no slave is available. This can be changed by calling scheduleJob.

    Parameters: job the job to register

    UNKNOWN: Register job with the scheduler.

    emitDCOPSignal

    public void emitDCOPSignal(String signal, byte[] data)
    Emit signal as DCOP signal from this object with data as arguments

    Parameters: signal the signal to emit data the data to send

    UNKNOWN: Emit signal as DCOP signal from this object with data as arguments

    find

    public static DCOPObjectInterface find(String objId)
    Try to find a dcop object with the given id. This function does not query the DCOPObjectProxy.

    Parameters: objId the object id to search

    Returns: the DCOPObject for the id objId.

    UNKNOWN: Try to find a dcop object with the given id.

    functions

    public ArrayList functions()

    functionsDynamic

    public ArrayList functionsDynamic()
    This function is of interest when you used an IDL compiler to generate the implementation for functions() but you still want to list some functions dynamically. Dynamically means that the methods may appear and vanish during runtime.

    Returns: A list of the additional functions, default is an empty list.

    See Also: Scheduler

    UNKNOWN: This function is of interest when you used an IDL compiler to generate the implementation for functions() but you still want to list some functions dynamically.

    getConnectedSlave

    public static Slave getConnectedSlave(KURL url)
    Requests a slave for use in connection-oriented mode.

    Parameters: url This defines the username,password,host & port to connect with. config Configuration data for the slave.

    Returns: A pointer to a connected slave or 0 if an error occurred.

    See Also: Scheduler Scheduler

    UNKNOWN: Requests a slave for use in connection-oriented mode.

    hasObject

    public static boolean hasObject(String objId)
    Checks whether an object with the given id is known in this process. DCOPObjectProxy

    Returns: true if an object with the questionable objId is known in this process. This query does not ask proxies.

    UNKNOWN: Checks whether an object with the given id is known in this process.

    interfaces

    public ArrayList interfaces()
    Returns the names of the interfaces, specific ones last. The functions gets reimplemented by the IDL compiler. If you don't use the IDL compiler, consider implementing this function manually if you want your object to be easily explorable.

    Returns: a list of interfaces

    See Also: Scheduler

    UNKNOWN: Returns the names of the interfaces, specific ones last.

    interfacesDynamic

    public ArrayList interfacesDynamic()
    This function is of interest when you used an IDL compiler to generate the implementation for interfaces() but you still want to list some interfaces dynamically. Dynamically means that they may appear and vanish during runtime.

    Returns: A list of the additional interfaces, default is an empty list.

    See Also: Scheduler

    UNKNOWN: This function is of interest when you used an IDL compiler to generate the implementation for interfaces() but you still want to list some interfaces dynamically.

    jobFinished

    public static void jobFinished(SimpleJob job, Slave slave)
    Called when a job is done.

    Parameters: job the finished job slave the slave that executed the job

    UNKNOWN: Called when a job is done.

    metaObject

    public QMetaObject metaObject()

    objectName

    public static String objectName(QObject arg1)
    Creates an object id for the QObject obj. This is done using the QObject.name() function.

    Parameters: obj the object whose name will be used

    Returns: the created object id

    UNKNOWN: Creates an object id for the QObject obj.

    objId

    public String objId()
    Returns the object id of the DCOPObject.

    Returns: the object's id

    UNKNOWN: Returns the object id of the DCOPObject.

    process

    public boolean process(String fun, byte[] data, StringBuffer replyType, byte[] replyData)

    processDynamic

    public boolean processDynamic(String fun, byte[] data, StringBuffer replyType, byte[] replyData)
    This function is of interest when you used an IDL compiler to generate the implementation for process() but you still want to dispatch some functions dynamically. Dynamically means that methods may appear and vanish during runtime.

    Parameters: fun is the normalized function signature. Such a signature usually looks like foobar(String,int). The return type, qualifiers like "const" etc. are not part of the signature. data the received data replyType write the reply type in this string replyData write the reply data in this array

    Returns: true if successful, false otherwise. The default implementation returns always false.

    See Also: Scheduler DCOPClient Scheduler DCOPClient

    UNKNOWN: This function is of interest when you used an IDL compiler to generate the implementation for process() but you still want to dispatch some functions dynamically.

    publishSlaveOnHold

    public static void publishSlaveOnHold()
    Send the slave that was put on hold back to KLauncher. This allows another process to take over the slave and resume the job that was started.

    UNKNOWN: Send the slave that was put on hold back to KLauncher.

    putSlaveOnHold

    public static void putSlaveOnHold(SimpleJob job, KURL url)
    Puts a slave on notice. A next job may reuse this slave if it requests the same URL. A job can be put on hold after it has emit'ed its mimetype. Based on the mimetype, the program can give control to another component in the same process which can then resume the job by simply asking for the same URL again.

    Parameters: job the job that should be stopped url the URL that is handled by the url

    UNKNOWN: Puts a slave on notice.

    registerWindow

    public static void registerWindow(QWidget wid)
    Send the slave that was put on hold back to KLauncher. This allows another process to take over the slave and resume the job the that was started. Register the mainwindow wid with the KIO subsystem Do not call this, it is called automatically from void KIO.Job.setWindow(QWidget).

    Parameters: wid the window to register

    UNKNOWN: Send the slave that was put on hold back to KLauncher.

    removeSlaveOnHold

    public static void removeSlaveOnHold()
    Removes any slave that might have been put on hold. If a slave was put on hold it will be killed.

    UNKNOWN: Removes any slave that might have been put on hold.

    scheduleJob

    public static void scheduleJob(SimpleJob job)
    Calling ths function makes that job gets scheduled for later execution, if multiple jobs are registered it might wait for other jobs to finish.

    Parameters: job the job to schedule

    UNKNOWN: Calling ths function makes that job gets scheduled for later execution, if multiple jobs are registered it might wait for other jobs to finish.

    setCallingDcopClient

    public void setCallingDcopClient(DCOPClient arg1)

    UNKNOWN:

    setObjId

    public boolean setObjId(String objId)
    Renames a dcop object, if no other with the same name exists Use with care, all dcop signals are disconnected

    Parameters: objId the new object id

    UNKNOWN: Renames a dcop object, if no other with the same name exists Use with care, all dcop signals are disconnected

    setupSlave

    protected void setupSlave(Slave slave, KURL url, String protocol, String proxy, boolean newSlave)

    slotCleanIdleSlaves

    protected void slotCleanIdleSlaves()

    slotScheduleCoSlave

    protected void slotScheduleCoSlave()

    slotSlaveConnected

    protected void slotSlaveConnected()

    slotSlaveDied

    public void slotSlaveDied(Slave slave)

    slotSlaveError

    protected void slotSlaveError(int error, String errorMsg)

    slotSlaveStatus

    public void slotSlaveStatus(int pid, String protocol, String host, boolean connected)

    slotUnregisterWindow

    protected void slotUnregisterWindow(QObject arg1)

    startJobDirect

    protected boolean startJobDirect()

    startStep

    protected void startStep()

    unregisterWindow

    public static void unregisterWindow(QObject wid)
    Unregisters the window registered by registerWindow().

    UNKNOWN: