Asynchronous management of movable components
Techniques for asynchronous management of physical components are disclosed. A request to perform an operation in a tape library, including a physical task to be performed by a component, is received. Based on the request, a message handler is initialized. The message handler executes in an execution thread. State data associated with the component is retrieved from persistent storage. Using the state data, a code object representing the component is instantiated. Using the message handler and the code object, instructions are transmitted to the component to perform the physical task. A process, executing in a different execution thread, receives a message from the component indicating completion of the physical task. Based on the message, another message handler is initialized that updates persistent storage associated with the component.
1. A non-transitory computer readable medium comprising instructions which, when executed by one or more hardware processors, cause performance of operations comprising:
receiving a first request to perform a first operation in a tape library, the first operation comprising a first physical task to be performed by a physical component;
based on the first request:
(a) initializing a first message handler executing in a first execution thread;
(b) retrieving, from persistent storage, state data associated with the physical component;
(c) instantiating, using the state data, a first code object representing the physical component; and
(d) transmitting, using at least the first message handler and the first code object, instructions to the physical component to perform the first physical task;
receiving, by a first process executing in a second execution thread different than the first execution thread, a first message from the physical component indicating completion of the physical task; and
based on the first message from the physical component:
(a) initializing a second message handler executing in a third execution thread; and
(b) updating persistent storage, by the second message handler, with first updated state data associated with the physical component.
2. The medium of claim 1 , wherein the operations further comprise:
receiving a second request to perform a second operation in the tape library, the second operation comprising a second physical task to be performed by the physical component;
based on the second request:
(a) initializing a third message handler executing in a fourth execution thread;
(b) retrieving, from persistent storage, the updated state data associated with the physical component;
(c) instantiating, using the updated state data, a second code object representing the physical component; and
(d) transmitting, using at least the third message handler and the second code object, instructions to the physical component to perform the second physical task;
receiving, by a second process executing in a fifth execution thread different than the fourth execution thread, a second message from the physical component indicating completion of the second physical task; and
based on the second message from the physical component:
(a) initializing a fourth message handler executing in a sixth execution thread; and
(b) updating persistent storage, by the fourth message handler, with second updated state data associated with the physical component.
3. The medium of claim 1 , wherein the operations further comprise:
receiving a second request to perform a second operation in the tape library, the second operation comprising a second physical task to be performed by the physical component;
transmitting, using at least a third message handler and a second code object representing the physical component, instructions to the physical component to perform the second physical task;
receiving a second message indicating a failure of the second physical task;
based on the second message indicating the failure:
(a) initializing a fourth message handler; and
(b) performing, by the fourth message handler, at least one remedial action associated with the failure.
4. The medium of claim 3 , wherein the at least one remedial action comprises undoing at least one system change associated with the second operation.
5. The medium of claim 3 , wherein the at least one remedial action comprises attempting to perform the physical task using a different physical component.
6. The medium of claim 3 , wherein the at least one remedial action comprises attempting to recover the first physical component.
7. The medium of claim 3 , wherein the second message indicating the failure is received from a monitoring process, based on expiration of a timer associated with the second physical task.
8. The medium of claim 1 , wherein state data associated with the physical component comprises a physical position of the physical component in the tape library and an idle status of the physical component.
9. The medium of claim 1 , wherein the first execution thread executes on a first processor in a server cluster and the second execution thread executes on a second processor in the server cluster.
10. The medium of claim 1 , wherein the operations further comprise:
terminating the first execution thread upon successfully transmitting instructions to the physical component.
11. The medium of claim 1 , wherein the second execution thread and the third execution thread correspond to a same execution thread.
12. The medium of claim 1 , wherein the second execution thread and the third execution thread correspond to different execution threads.
13. A system comprising:
one or more hardware processors; and
one or more non-transitory computer-readable media storing instructions, which when executed by the one or more hardware processors, cause execution of operations comprising:
receiving a first request to perform a first operation in a tape library, the first operation comprising a first physical task to be performed by a physical component;
based on the first request:
(a) initializing a first message handler executing in a first execution thread;
(b) retrieving, from persistent storage, state data associated with the physical component;
(c) instantiating, using the state data, a first code object representing the physical component; and
(d) transmitting, using at least the first message handler and the first code object, instructions to the physical component to perform the first physical task;
receiving, by a first process executing in a second execution thread different than the first execution thread, a first message from the physical component indicating completion of the physical task; and
based on the first message from the physical component:
(a) initializing a second message handler executing in a third execution thread; and
(b) updating persistent storage, by the second message handler, with first updated state data associated with the physical component.
14. The system of claim 13 , wherein the operations further comprise:
receiving a second request to perform a second operation in the tape library, the second operation comprising a second physical task to be performed by the physical component;
based on the second request:
(e) initializing a third message handler executing in a fourth execution thread;
(f) retrieving, from persistent storage, the updated state data associated with the physical component;
(g) instantiating, using the updated state data, a second code object representing the physical component; and
(h) transmitting, using at least the third message handler and the second code object, instructions to the physical component to perform the second physical task;
receiving, by a second process executing in a fifth execution thread different than the fourth execution thread, a second message from the physical component indicating completion of the second physical task; and
based on the second message from the physical component:
(c) initializing a fourth message handler executing in a sixth execution thread; and
(d) updating persistent storage, by the fourth message handler, with second updated state data associated with the physical component.
15. The system of claim 13 , wherein the operations further comprise:
receiving a second request to perform a second operation in the tape library, the second operation comprising a second physical task to be performed by the physical component;
transmitting, using at least a third message handler and a second code object representing the physical component, instructions to the physical component to perform the second physical task;
receiving a second message indicating a failure of the second physical task;
based on the second message indicating the failure:
(c) initializing a fourth message handler; and
(d) performing, by the fourth message handler, at least one remedial action associated with the failure.
16. The system of claim 15 , wherein the at least one remedial action comprises undoing at least one system change associated with the second operation.
17. The system of claim 15 , wherein the at least one remedial action comprises attempting to recover the first physical component.
18. The system of claim 13 , wherein state data associated with the physical component comprises a physical position of the physical component in the tape library and an idle status of the physical component.
19. The system of claim 13 , wherein the operations further comprise:
terminating the first execution thread upon successfully transmitting instructions to the physical component.
20. A method comprising:
receiving a first request to perform a first operation in a tape library, the first operation comprising a first physical task to be performed by a physical component;
based on the first request:
(a) initializing a first message handler executing in a first execution thread;
(b) retrieving, from persistent storage, state data associated with the physical component;
(c) instantiating, using the state data, a first code object representing the physical component; and
(d) transmitting, using at least the first message handler and the first code object, instructions to the physical component to perform the first physical task;
receiving, by a first process executing in a second execution thread different than the first execution thread, a first message from the physical component indicating completion of the physical task; and
based on the first message from the physical component:
(a) initializing a second message handler executing in a third execution thread; and
(b) updating persistent storage, by the second message handler, with first updated state data associated with the physical component;
wherein the method is performed by at least one device comprising a hardware processor.