|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 11701 (0x2db5)
Types: TextFile
Names: »B«
└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
└─⟦5cb1d1d7f⟧ »DATA«
└─⟦3b1ee7bd8⟧
└─⟦this⟧
with Directory_Tools;
with System_Utilities;
with String_Utilities;
with Operator;
with Time_Utilities;
with Table_Formatter;
with Io;
with Batch_Stream;
with Batch_Commands;
with Log;
with Profile;
package body Batch_Queue is
Ill_Formed_Name : exception;
procedure Submit (Job : String := "";
Start_Time : String := ">>YY/MM/DD HH:MM:SS<<";
To_Stream : Natural := 1;
Job_Context : String := "";
Username : String := "";
Error_Filename : String := "";
Input_Filename : String := "";
Output_Filename : String := "";
Restartable : Boolean := False;
Response : String := "<PROFILE>") is
The_Job : Batch_Stream.Job_Descriptor;
The_Command : Batch_Commands.Command;
use Directory_Tools;
function Job_Context_Name (Supplied_Name : String) return String is
Hndl : Directory_Tools.Object.Handle;
begin
if Supplied_Name = "" then
return Naming.Expanded_Name ("$");
else
Hndl := Directory_Tools.Naming.Resolution (Supplied_Name);
if Object.Is_Nil (Hndl) then
Log.Put_Line ("Ill formed name " & Supplied_Name,
Profile.Error_Msg);
raise Ill_Formed_Name;
elsif not Object.Equal (Object.Class (Hndl),
Object.Library_Class) then
Log.Put_Line (Supplied_Name & " is not a library",
Profile.Error_Msg);
raise Ill_Formed_Name;
else
return Naming.Full_Name (Hndl);
end if;
end if;
end Job_Context_Name;
function Error_Name (Supplied_Name : String) return String is
begin
if Supplied_Name = "" then
return (System_Utilities.Home_Library & ".batch_error_" &
Time_Utilities.Image
(Time_Utilities.Get_Time,
Time_Utilities.Ada, Time_Utilities.Ada));
elsif Supplied_Name (Supplied_Name'First) = '!' then
if Naming.Is_Well_Formed (Supplied_Name) then
return Supplied_Name;
else
Log.Put_Line ("Ill formed name - " & Supplied_Name,
Profile.Error_Msg);
raise Ill_Formed_Name;
end if;
else
if Naming.Is_Well_Formed (Supplied_Name) then
return Naming.Expanded_Name (Supplied_Name);
else
Log.Put_Line ("Ill formed name - " & Supplied_Name,
Profile.Error_Msg);
raise Ill_Formed_Name;
end if;
end if;
end Error_Name;
function Input_Name (Supplied_Name : String) return String is
begin
if Supplied_Name = "" then
return Supplied_Name;
elsif Supplied_Name (Supplied_Name'First) = '!' then
if Naming.Is_Well_Formed (Supplied_Name) then
return Supplied_Name;
else
Log.Put_Line ("Ill formed name - " & Supplied_Name,
Profile.Error_Msg);
raise Ill_Formed_Name;
end if;
else
if Naming.Is_Well_Formed (Supplied_Name) then
return Naming.Expanded_Name (Supplied_Name);
else
Log.Put_Line ("Ill formed name - " & Supplied_Name,
Profile.Error_Msg);
raise Ill_Formed_Name;
end if;
end if;
end Input_Name;
function Output_Name (Supplied_Name : String) return String is
begin
if Supplied_Name = "" then
return (System_Utilities.Home_Library & ".batch_output_" &
Time_Utilities.Image
(Time_Utilities.Get_Time,
Time_Utilities.Ada, Time_Utilities.Ada));
elsif Supplied_Name (Supplied_Name'First) = '!' then
if Naming.Is_Well_Formed (Supplied_Name) then
return Supplied_Name;
else
Log.Put_Line ("Ill formed name - " & Supplied_Name,
Profile.Error_Msg);
raise Ill_Formed_Name;
end if;
else
if Naming.Is_Well_Formed (Supplied_Name) then
return Naming.Expanded_Name (Supplied_Name);
else
Log.Put_Line ("Ill formed name - " & Supplied_Name,
Profile.Error_Msg);
raise Ill_Formed_Name;
end if;
end if;
end Output_Name;
function Response_String (Supplied_String : String) return String is
begin
return Profile.Image (Profile.Value (Supplied_String));
end Response_String;
begin
if Username = "" or
String_Utilities.Equal
(Str1 => Username,
Str2 => System_Utilities.User_Name
(For_Session => System_Utilities.Get_Session),
Ignore_Case => True) then
The_Job := Batch_Stream.Make
(Job_Number => Batch_Stream.Job_Identifier'First,
Command => Job,
Context => Job_Context_Name (Job_Context),
User_Name => System_Utilities.User_Name,
Error_Filename => Error_Name (Error_Filename),
Input_Filename => Input_Name (Input_Filename),
Output_Filename => Output_Name (Output_Filename),
Start_Time => Time_Utilities.Value (Start_Time),
Restartable => Restartable,
Response => Response_String (Response));
The_Command := Batch_Commands.Make (Stream_Number => To_Stream,
Inst => Batch_Commands.Submit,
Job_Description => The_Job);
Batch_Commands.Put (The_Command);
else
Operator.Enable_Privileges (Enable => True);
if Operator.Privileged_Mode then
The_Job := Batch_Stream.Make
(Job_Number => Batch_Stream.Job_Identifier'First,
Command => Job,
Context => Job_Context_Name (Job_Context),
User_Name => Username,
Error_Filename => Error_Name (Error_Filename),
Input_Filename => Input_Name (Input_Filename),
Output_Filename => Output_Name (Output_Filename),
Start_Time => Time_Utilities.Value (Start_Time),
Restartable => Restartable,
Response => Response_String (Response));
The_Command := Batch_Commands.Make
(Stream_Number => To_Stream,
Inst => Batch_Commands.Submit,
Job_Description => The_Job);
Batch_Commands.Put (The_Command);
else
Io.Echo ("Insufficient privileges to run as " & Username);
end if;
end if;
exception
when Constraint_Error =>
declare
T : Time_Utilities.Time;
begin
T := Time_Utilities.Value (Start_Time);
Log.Put_Line ("Some Constraint Error Raised",
Profile.Error_Msg);
exception
when Constraint_Error =>
Log.Put_Line ("Illegal time specification - " & Start_Time,
Profile.Error_Msg);
end;
Log.Put_Line ("Submit failed", Profile.Negative_Msg);
when Ill_Formed_Name =>
Log.Put_Line ("Submit failed", Profile.Negative_Msg);
end Submit;
procedure Display (Streams : Natural := 0) is
use Batch_Stream;
package Table is new Table_Formatter (5);
The_Iter : Batch_Stream.Iterator;
The_Job : Batch_Stream.Job_Descriptor;
procedure Display_All_Streams is
new Batch_Stream.Traverse_Streams (Display);
begin
if Streams = 0 then
Display_All_Streams;
else
Table.Header (S => "Queue Id", Format => Table.Centered);
Table.Header (S => "User", Format => Table.Centered);
Table.Header (S => "Start Time", Format => Table.Centered);
Table.Header (S => "State", Format => Table.Centered);
Table.Header (S => "Command", Format => Table.Centered);
Batch_Stream.Initialize (Streams, The_Iter);
while not Batch_Stream.Done (The_Iter) loop
The_Job := Batch_Stream.Value (The_Iter);
if Batch_Stream.State (The_Job) = Batch_Stream.Running or
Batch_Stream.State (The_Job) = Batch_Stream.Waiting then
Table.Item (S => Batch_Stream.Job_Identifier'Image
(Batch_Stream.Number (The_Job)));
Table.Item (S => Batch_Stream.Username (The_Job));
Table.Item (S => Time_Utilities.Image
(Batch_Stream.Start_Time (The_Job),
Contents => Time_Utilities.Both));
Table.Item (S => Batch_Stream.Job_State'Image
(Batch_Stream.State (The_Job)));
Table.Item (S => Batch_Stream.Command (The_Job));
end if;
Batch_Stream.Next (The_Iter);
end loop;
Io.Put_Line ("STREAM" & Natural'Image (Streams));
Table.Display (On_File => Io.Standard_Output);
Io.New_Line;
end if;
exception
when Batch_Stream.File_Access_Error =>
Io.Echo ("Stream" & Natural'Image (Streams) & " does not exist");
end Display;
procedure Cancel (Queue_Id : Natural; In_Stream : Natural) is
The_Job : Batch_Stream.Job_Descriptor := Batch_Stream.Nil;
The_Command : Batch_Commands.Command;
begin
Batch_Stream.Set_Number (Of_Job => The_Job, To => Queue_Id);
The_Command := Batch_Commands.Make (Stream_Number => In_Stream,
Inst => Batch_Commands.Cancel,
Job_Description => The_Job);
Batch_Commands.Put (The_Command => The_Command);
end Cancel;
procedure Kill (Stream : Natural) is
The_Job : Batch_Stream.Job_Descriptor := Batch_Stream.Nil;
The_Command : Batch_Commands.Command;
begin
The_Command := Batch_Commands.Make (Stream_Number => Stream,
Inst => Batch_Commands.Shutdown,
Job_Description => The_Job);
Batch_Commands.Put (The_Command);
end Kill;
end Batch_Queue;