Commit 3b0f2595 authored by Mart Lubbers's avatar Mart Lubbers Committed by Haye Böhm

Add storing symbols to the engine

parent 8ec5b7ac
......@@ -99,8 +99,7 @@ getDomain
startMode :: String -> Task ()
startMode executable
= startDistributedEngine executable
>>| get serverRoleShare
= get serverRoleShare
>>- \role = case role of
DomainServer domain -> startAuthEngine domain >>| loginAndManageWorkList "Service engineer application" (myTasks True)
Server domain -> startAuthEngine domain >>| loginRemote (myTasks False)
......@@ -141,6 +140,6 @@ Start world
= startEngineWithOptions opts [ publish "/" (\_-> startMode (IF_WINDOWS "examples.exe" "examples"))
] world
where
opts [] = \op->(Just op, ["Started server on port: " +++ toString op.serverPort])
opts [] = \op->(Just {op&distributed=True}, ["Started server on port: " +++ toString op.serverPort])
opts ["-p",p:as] = appFst (fmap (\o->{o & serverPort=toInt p})) o opts as
opts [a:as] = opts as
......@@ -23,6 +23,7 @@ import iTasks.WF.Definition
, persistTasks :: Bool
, autoLayout :: Bool
, timeout :: Maybe Int // The timeout
, distributed :: Bool
, webDirPath :: FilePath // Location of public files that are served by the iTask webserver
, storeDirPath :: FilePath // Location of the application's persistent data files
, tempDirPath :: FilePath // Location for temporary files used in tasks
......
......@@ -25,6 +25,7 @@ import iTasks.Internal.IWorld, iTasks.Internal.TaskEval, iTasks.Internal.TaskSto
import iTasks.Internal.Util
import iTasks.Internal.TaskServer
import iTasks.Internal.EngineTasks
import iTasks.Internal.Distributed.Symbols
from iTasks.Extensions.DateTime import toDate, toTime, instance == Date, instance == Time
......@@ -44,14 +45,23 @@ defaultEngineOptions world
# options =
{ appName = appName
, appPath = appPath
, appVersion = appVersion
, appVersion = appVersion
, serverPort = IF_POSIX_OR_WINDOWS 8080 80
<<<<<<< HEAD
, serverUrl = "http://localhost/"
, keepaliveTime = {tv_sec=300,tv_nsec=0} // 5 minutes
, sessionTime = {tv_sec=60,tv_nsec=0} // 1 minute, (the client pings every 10 seconds by default)
, persistTasks = False
, autoLayout = True
, timeout = Just 500
=======
, serverUrl = "http://localhost/"
, keepaliveTime = 300 // 5 minutes
, sessionTime = 60 // 1 minute, (the client pings every 10 seconds by default)
, persistTasks = False
, autoLayout = True
, distributed = False
>>>>>>> Add storing symbols to the engine
, webDirPath = appDir </> appName +++ "-www"
, storeDirPath = appDir </> appName +++ "-data" </> "stores"
, tempDirPath = appDir </> appName +++ "-data" </> "tmp"
......@@ -133,6 +143,8 @@ startEngineWithOptions initFun publishable world
# iworld = createIWorld (fromJust mbOptions) world
# (res,iworld) = initJSCompilerState iworld
| res =:(Error _) = show ["Fatal error: " +++ fromError res] (destroyIWorld iworld)
# (_, iworld) = if options.distributed (storeSymbols options.appName iworld) (Ok "", iworld)
| res =:(Error _) = show ["Fatar error: " +++ fromError res] (destroyIWorld iworld)
# iworld = serve [TaskWrapper removeOutdatedSessions] (tcpTasks options.serverPort options.keepaliveTime) (timeout options.timeout) iworld
= destroyIWorld iworld
where
......
......@@ -10,7 +10,7 @@ import iTasks.Extensions.Distributed._Formatter
import iTasks.Extensions.Distributed._Util
import iTasks.Extensions.Distributed._Types
import iTasks.Extensions.Distributed._SDS
import iTasks.Extensions.Distributed.Engine
import iTasks.Internal.Distributed.Symbols
import iTasks.Extensions.Distributed._Evaluation
from iTasks.Extensions.Distributed.Task import :: Domain(..)
from iTasks.Extensions.Distributed._Util import repeatClient
......
......@@ -12,7 +12,6 @@ import iTasks.Extensions.Distributed._Types
import iTasks.Extensions.Distributed.Instance
import iTasks.Extensions.Distributed._SDS
import iTasks.Extensions.Distributed._Attributes
import iTasks.Extensions.Distributed.Engine
from iTasks.Extensions.Distributed.Task import :: Domain(..)
remoteAssignTask :: !TaskAttributes (Task a) Domain -> Task a | iTask a
......
......@@ -20,7 +20,7 @@ from iTasks.Extensions.User import currentUser, :: User(..), :: UserTitle, :: Ro
from iTasks.Internal.SDS import :: SDS, :: ReadWriteShared, :: RWShared, :: ReadOnlyShared, :: ROShared
from iTasks.Extensions.Distributed.Authentication import currentDomain
import qualified iTasks.WF.Tasks.SDS as C
import iTasks.Extensions.Distributed.Engine
import iTasks.Internal.Distributed.Symbols
instance @: worker (Task a) | iTask a & toUserConstraint worker
where
......
......@@ -8,7 +8,7 @@ import iTasks.Extensions.Distributed.Instance
import iTasks.Extensions.Distributed._Attributes
import qualified Data.Map as DM
import Text.Encodings.Base64
import iTasks.Extensions.Distributed.Engine
import iTasks.Internal.Distributed.Symbols
from iTasks.Internal.Serialization import dynamicJSONEncode, dynamicJSONDecode
from iTasks.UI.Editor.Common import emptyEditor
......
......@@ -22,7 +22,7 @@ from iTasks.SDS.Sources.System import currentDateTime
from iTasks.Extensions.User import currentUser, :: User(..), :: UserTitle, :: Role, :: UserId, assign, workerAttributes, :: Password, :: Username, workAs, :: Credentials{..}, users
from iTasks.SDS.Definition import :: ReadWriteShared, :: RWShared, :: ReadOnlyShared
from iTasks.WF.Tasks.Core import accWorld
from iTasks.Extensions.Distributed.Engine import startDistributedEngine
import iTasks.Internal.Distributed.Symbols
from iTasks.Extensions.Distributed.Instance import instanceServer, instanceClient, instanceFilter, instanceClameFilter
from Data.Map import :: Map
from iTasks.Extensions.Admin.WorkflowAdmin import workflow, class toWorkflow(..), :: Workflow, publish, :: PublishedTask{..}, :: TaskWrapper(..), manageWorklist, instance toWorkflow (Task a), instance toWorkflow (WorkflowContainer a), instance toWorkflow (a -> Task b), instance toWorkflow (ParamWorkflowContainer a b), :: WorkflowContainer, :: ParamWorkflowContainer
......
......@@ -131,6 +131,7 @@ createClientIWorld serverURL currentInstance
, persistTasks = False
, autoLayout = True
, timeout = Just 100
, distributed = False
, webDirPath = locundef "webDirectory"
, storeDirPath = locundef "dataDirectory"
, tempDirPath = locundef "tempDirectory"
......
definition module iTasks.Extensions.Distributed.Engine
definition module iTasks.Internal.Distributed.Symbols
from iTasks.WF.Definition import class iTask
from iTasks.WF.Definition import :: Task, generic gEq, generic gDefault, generic JSONDecode, generic JSONEncode, generic gText, generic gEditor, :: Editor
......@@ -6,13 +6,11 @@ from Data.Maybe import :: Maybe
from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode
from iTasks.Internal.Generic.Visualization import :: TextFormat(..)
from symbols_in_program import :: Symbol
from iTasks.Internal.IWorld import :: IWorld
from Data.Error import :: MaybeError
from iTasks.WF.Definition import :: TaskException
/*
* Start the distributed iTasks engine.
*
* @param executable Path to executable (or library) containing the code of this server.
*/
startDistributedEngine :: String -> Task ()
storeSymbols :: String !*IWorld -> (MaybeError TaskException String, !*IWorld)
accSymbols :: ({#Symbol} -> a) -> Task a | iTask a
......
implementation module iTasks.Extensions.Distributed.Engine
implementation module iTasks.Internal.Distributed.Symbols
import iTasks
from iTasks.WF.Tasks.Core import accWorld
from iTasks.Internal.SDS import read, write
import symbols_in_program
from iTasks.Internal.IWorld import :: IWorld{world}
from Data.Error import :: MaybeError(..)
from iTasks.WF.Definition import :: TaskException, :: Task(..), :: TaskResult, :: TaskEvalOpts, :: Event(..), :: Set
from iTasks.Internal.Task import mkInstantTask
from iTasks.Internal.TaskState import :: TaskTree
from iTasks.WF.Definition import class iTask
from iTasks.Internal.SDS import :: ReadWriteShared, :: RWShared, :: Shared
from iTasks.WF.Definition import :: Task, generic gEq, generic gDefault, generic JSONDecode, generic JSONEncode, generic gText, generic gEditor, :: Editor, :: TaskId
from Data.Maybe import :: Maybe
from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode
from iTasks.Internal.Generic.Visualization import :: TextFormat(..)
import StdFile
//from iTasks.WF.Tasks.Core import accWorld
//from iTasks.Internal.SDS import read, write
import symbols_in_program
//from iTasks.Internal.IWorld import :: IWorld{world}
//from Data.Error import :: MaybeError(..)
//from iTasks.WF.Definition import :: TaskException, :: Task(..), :: TaskResult, :: TaskEvalOpts, :: Event(..), :: Set
//from iTasks.Internal.Task import mkInstantTask
//from iTasks.Internal.TaskState import :: TaskTree
//from iTasks.WF.Definition import class iTask
//from iTasks.Internal.SDS import :: ReadWriteShared, :: RWShared, :: Shared
//from iTasks.WF.Definition import :: Task, generic gEq, generic gDefault, generic JSONDecode, generic JSONEncode, generic gText, generic gEditor, :: Editor, :: TaskId
//from Data.Maybe import :: Maybe
//from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode
//from iTasks.Internal.Generic.Visualization import :: TextFormat(..)
//import StdFile
import dynamic_string
import Text.Encodings.Base64
from iTasks.WF.Combinators.Common import @!, >>-
from iTasks.WF.Tasks.SDS import set
from iTasks.SDS.Sources.Store import :: SDS, sharedStore
import StdTuple
import iTasks.Internal.SDS
import iTasks.Internal.Task
import iTasks.Internal.IWorld
//from iTasks.WF.Combinators.Common import @!, >>-
//from iTasks.WF.Tasks.SDS import set
//from iTasks.SDS.Sources.Store import :: SDS, sharedStore
//import StdTuple
symbolsShare :: Shared String
symbolsShare = sharedStore "symbols" ""
startDistributedEngine :: String -> Task ()
startDistributedEngine executable = storeSymbols executable
storeSymbols :: String -> Task ()
storeSymbols file = mkInstantTask eval
where
eval taskId iworld=:{IWorld|world}
# (symbols, world) = accFiles (read_symbols file) world
# iworld = {IWorld| iworld & world = world}
# val = base64Encode (copy_to_string symbols)
# (res,iworld) = write val symbolsShare iworld
= case res of
Ok _ = (Ok (), iworld)
Error e = (Error e, iworld)
storeSymbols :: String !*IWorld -> (MaybeError TaskException String, !*IWorld)
storeSymbols file iworld
# (symbols, iworld) = accFiles (read_symbols file) iworld
# val = base64Encode (copy_to_string symbols)
# (res, iworld) = write val symbolsShare iworld
| isError res = (liftError res, iworld)
= (Ok val, iworld)
accSymbols :: ({#Symbol} -> a) -> Task a | iTask a
accSymbols fun = mkInstantTask eval
......@@ -56,4 +56,3 @@ where
# (val, iworld) = read symbolsShare iworld
= case val of
Ok val = let (Task eval`) = taskfun (fst (copy_from_string (base64Decode val))) in eval` event evalOpts state iworld
......@@ -6,7 +6,7 @@ from Data.Maybe import :: Maybe
from Data.Error import :: MaybeError(..), :: MaybeErrorString(..)
from Data.Set import :: Set
from Data.Queue import :: Queue
from StdFile import class FileSystem
from StdFile import class FileSystem, class FileEnv
from System.Time import :: Timestamp, :: Timespec
from Text.GenJSON import :: JSONNode
from iTasks.Engine import :: EngineOptions
......@@ -161,3 +161,4 @@ iworldLocalDateTime` :: !*IWorld -> (!DateTime, !*IWorld)
iworldResource :: (*Resource -> (Bool, *Resource)) *IWorld -> (*[*Resource], *IWorld)
instance FileSystem IWorld
instance FileEnv IWorld
......@@ -15,8 +15,8 @@ import Data.Integer
import iTasks.SDS.Combinators.Common
from StdFile import class FileSystem(..)
from StdFile import instance FileSystem World
from StdFile import class FileSystem(..), class FileEnv(..), :: Files
from StdFile import instance FileSystem World, instance FileEnv World
from StdFunc import const, o, seqList, :: St
from StdMisc import abort
from StdOrdList import sortBy
......@@ -185,3 +185,12 @@ where
sfopen filename mode iworld=:{IWorld|world}
# (ok,file,world) = sfopen filename mode world
= (ok,file,{IWorld|iworld & world = world})
instance FileEnv IWorld
where
accFiles accfun iworld=:{IWorld|world}
# (x, world) = accFiles accfun world
= (x, {IWorld | iworld & world=world})
appFiles appfun iworld=:{IWorld|world}
# world = appFiles appfun world
= {IWorld | iworld & world=world}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment