-- AlpineRemoteExportImpl.mesa
-- Last edited by
--   MBrown on February 1, 1984 3:34:05 pm PST
--   Kolling on June 3, 1983 5:57 pm

-- NOTES

-- If calls to these procedures are FORKed, there is no way for anyone outside of this
--module to determine whether or not exporting has succeeded.  But there doesn't seem
--to be anything to do but call a wizard when export fails, anyway.
-- Repeated export failure due to communications problems should be noted in an
--activity log.

  DIRECTORY
    AlpineDebugRpcControl,
    AlpineFileRpcControl,
    AlpineOwnerRpcControl,
    AlpineVolumeRpcControl,
    AlpineControl USING [],
    AlpineIdentity USING [myFileStore, myEncryptionKey],
    AlpineTransactionRpcControl,
    AlpineTransMgrRpcControl,
    FilePrivate,
    RPC,
    Process;

AlpineRemoteExportImpl: PROGRAM
  IMPORTS
    AlpineDebugRpcControl,
    AlpineFileRpcControl,
    AlpineOwnerRpcControl,
    AlpineVolumeRpcControl,
    AlpineIdentity,
    AlpineTransactionRpcControl,
    AlpineTransMgrRpcControl,
    FilePrivate,
    RPC,
    Process
  EXPORTS
    AlpineControl
  = BEGIN

  version: RPC.VersionRange = [3, 3];
  exportRetryInterval: Process.Ticks ← Process.SecondsToTicks[60];

  ExportInterfaces: PUBLIC PROC [] = {
    AlpineTransMgrExportProcess[];
    AlpineTransactionExportProcess[];
    AlpineDebugExportProcess[];
    AlpineFileExportProcess[];
    AlpineOwnerExportProcess[];
    AlpineVolumeExportProcess[];
    };

  AlpineTransMgrExportProcess: PROC [] = {
    DO
      {
      AlpineTransMgrRpcControl.ExportInterface[
        interfaceName: [type: "AlpineTransMgr.alpine", instance: AlpineIdentity.myFileStore,
           version: version],
        user: AlpineIdentity.myFileStore, password: AlpineIdentity.myEncryptionKey !
          RPC.ExportFailed => { IF why = communications THEN GOTO Wait }];
      RETURN;
      EXITS
        Wait => Process.Pause[exportRetryInterval];
      }
      ENDLOOP;
    };

  AlpineTransactionExportProcess: PROC [] = {
    DO
      {
      AlpineTransactionRpcControl.ExportInterface[
        interfaceName: [type: "AlpineTransaction.alpine", instance: AlpineIdentity.myFileStore,
           version: version],
        user: AlpineIdentity.myFileStore, password: AlpineIdentity.myEncryptionKey !
          RPC.ExportFailed => { IF why = communications THEN GOTO Wait }];
      RETURN;
      EXITS
        Wait => Process.Pause[exportRetryInterval];
      }
      ENDLOOP;
    };

  AlpineDebugExportProcess: PROC [] = {
    DO
      {
      AlpineDebugRpcControl.ExportInterface[
        interfaceName: [type: "AlpineDebug.alpine", instance: AlpineIdentity.myFileStore,
           version: version],
        user: AlpineIdentity.myFileStore, password: AlpineIdentity.myEncryptionKey,
        parameterStorage: [gc: FilePrivate.stdPZone] !
          RPC.ExportFailed => { IF why = communications THEN GOTO Wait }];
      RETURN;
      EXITS
        Wait => Process.Pause[exportRetryInterval];
      }
      ENDLOOP;
    };

AlpineFileExportProcess: PROC [] = {
    DO
      {
      AlpineFileRpcControl.ExportInterface[
        interfaceName: [type: "AlpineFile.alpine", instance: AlpineIdentity.myFileStore,
           version: version],
        user: AlpineIdentity.myFileStore, password: AlpineIdentity.myEncryptionKey,
        parameterStorage: [gc: FilePrivate.stdPZone] !
          RPC.ExportFailed => { IF why = communications THEN GOTO Wait }];
      RETURN;
      EXITS
        Wait => Process.Pause[exportRetryInterval];
      }
      ENDLOOP;
    };

  AlpineOwnerExportProcess: PROC [] = {
    DO
      {
      AlpineOwnerRpcControl.ExportInterface[
        interfaceName: [type: "AlpineOwner.alpine", instance: AlpineIdentity.myFileStore,
           version: version],
        user: AlpineIdentity.myFileStore, password: AlpineIdentity.myEncryptionKey,
        parameterStorage: [gc: FilePrivate.stdPZone] !
          RPC.ExportFailed => { IF why = communications THEN GOTO Wait }];
      RETURN;
      EXITS
        Wait => Process.Pause[exportRetryInterval];
      }
      ENDLOOP;
    };

  AlpineVolumeExportProcess: PROC [] = {
    DO
      {
      AlpineVolumeRpcControl.ExportInterface[
        interfaceName: [type: "AlpineVolume.alpine", instance: AlpineIdentity.myFileStore,
           version: version],
        user: AlpineIdentity.myFileStore, password: AlpineIdentity.myEncryptionKey,
        parameterStorage: [gc: FilePrivate.stdPZone] !
          RPC.ExportFailed => { IF why = communications THEN GOTO Wait }];
      RETURN;
      EXITS
        Wait => Process.Pause[exportRetryInterval];
      }
      ENDLOOP;
    };

END.--AlpineRemoteExportImpl