[ Back ]
-- resource.rpd
-- michael chen
-- this version includes a service (internally in the server architecture),
-- just to see how the client ID gets passed around in services


-- typedefs

type RType is integer;    -- HTTP Server Request Type (varies latency)
type ProcessorRateType is integer;
OpenGraph : RType is 30;
FetchPage : RType is 40;
Highlight : RType is 20;
PRate : ProcessorRateType is 50;

sec : integer is 1;
min : integer is 60 * sec;
hr : integer is 60 * min;


-- services

type SQLService(type T) is interface
action in  SQL_Response(Id : T);
       out  SQL_Command(Id : T);
end;


-- client modules


type WWWBrowser is interface
action in  InResponse();
       out  Command(R : RType), Java_Execution();
behavior
begin
   start ||> 
      Command(FetchPage);
      Command(OpenGraph) after 5;
      Command(Highlight) after 12;;
   InResponse ||> Java_Execution;;
end WWWBrowser;


type JavaBasedCollaboration is interface
action in  InJava_Execution(), InJava_Protocol();
       out  Java_Object();
behavior
begin
   InJava_Execution ||> Java_Object;;
end JavaBasedCollaboration;


-- client architecture


type Client is interface
action in  InResponse(), InJava_Protocol();
       out  OutCommand(R : RType), OutJava_Object();
end Client;


architecture ClientArch() for Client is
   W : WWWBrowser;
   J : JavaBasedCollaboration;
connect
   (?R in RType) W.Command(?R) ||> OutCommand(?R);
   InResponse ||> W.InResponse;
   J.Java_Object ||> OutJava_Object;
   InJava_Protocol ||> J.InJava_Protocol;
   W.Java_Execution ||> J.InJava_Execution;
end ClientArch;


-- server modules



type HTTPServer is interface
action in  InCommand(Id : Client; R : RType);
       out  Response(Id : Client);
requires
   function Latency(R : RType;I : Integer) return integer;
behavior
begin
   (?C in Client, ?R in RType, ?I in Integer)InCommand(?C, ?R) at ?I ||>
      Response(?C) after Latency(?R,?I);;
end HTTPServer;


type Res_Mang_Iface is interface
provides
   function Latency(R : RType; I : Integer) return integer;
behavior
workload : var integer := 0;
ic : var integer := 0;   -- internal clock
ad : var integer;   -- approximate delay
temp : var integer := 0;
function Latency(R : RType; I : Integer) return integer is
  begin
     if not($ic = I) then 
       workload := $workload - (PRate * (I - $ic));
       if ($workload < 0) then 
	 workload := 0;
	 end if;
       ic := I;
     end if;
       workload := $workload + R;
       ad := $workload/PRate;
       temp := $workload mod PRate;
       if ($temp = 0) then
	 return($ad);
	 end if;
       return($ad + 1);
  end;
end;


type SessionServer is interface
action in  InJava_Object(Id : Client);
       out  Java_Protocol(Id : Client);
service CommandGiver : SQLService(Client);
behavior
begin
   (?C in Client) InJava_Object(?C) ||> CommandGiver.SQL_Command(?C);;
   (?C in Client) CommandGiver.SQL_Response(?C) ||> Java_Protocol(?C);;
end SessionServer;


type Postgres is interface
service  CommandReceiver : dual SQLService(Client);
behavior
begin
   (?C in Client) CommandReceiver.SQL_Command(?C) ||> 
	CommandReceiver.SQL_Response(?C);;
end Postgres;


-- server architecture


type Server is interface
action in  InCommand(Id : Client; R : RType), InJava_Object(Id : Client);
       out  OutResponse(Id : Client), OutJava_Protocol(Id : Client);
end Server;


architecture ServerArch() for Server is
   HTTP : HTTPServer;
   SESS : SessionServer;
   POST : Postgres;
   RES : Res_Mang_Iface;
connect
   (?C in Client, ?R in RType) InCommand(?C, ?R) ||> HTTP.InCommand(?C, ?R);
   (?C in Client) HTTP.Response(?C) ||> OutResponse(?C);
   (?C in Client) InJava_Object(?C) ||> SESS.InJava_Object(?C);
   (?C in Client) SESS.Java_Protocol(?C) ||> OutJava_Protocol(?C);
   SESS.CommandGiver to POST.CommandReceiver;
   HTTP.Latency to RES.Latency;
end ServerArch;


-- ail super architecture


architecture ail()
is
   C1, C2 : Client is ClientArch();
   S : Server is ServerArch();
connect
   (?C in Client, ?R in RType) ?C.OutCommand(?R) ||> S.InCommand(?C, ?R);
   (?C in Client) S.OutResponse(?C) ||> ?C.InResponse;
   (?C in Client) ?C.OutJava_Object ||> S.InJava_Object(?C);
   (?C in Client) S.OutJava_Protocol(?C) ||> ?C.InJava_Protocol;
end ail;





















[ Back ]

© 1996 TRW Inc. All rights reserved.