Class LogicModule<T extends DBHandlerConf>

    • Field Detail

      • LOGGER

        protected static final org.apache.logging.log4j.Logger LOGGER
        Logger.
      • DEBUG_ENABLED

        protected static final boolean DEBUG_ENABLED
        Indicates if debug is enabled.
      • hostname

        protected String hostname
        LogicModule hostname.
      • port

        protected int port
        LogicModule port.
      • DC_PUBLIC_NAMESPACE

        public static final String DC_PUBLIC_NAMESPACE
        Name of public namespace DataClay (for DataClay classes).
        See Also:
        Constant Field Values
      • DC_REGISTRATOR

        public static final String DC_REGISTRATOR
        Name of DataClay registrator (for DataClay classes).
        See Also:
        Constant Field Values
      • DEFAULT_JAVA_NS_SUFFIX

        public static final String DEFAULT_JAVA_NS_SUFFIX
        Suffix for default java namespace.
        See Also:
        Constant Field Values
      • DEFAULT_PYTHON_NS_SUFFIX

        public static final String DEFAULT_PYTHON_NS_SUFFIX
        Suffix for default python namespace.
        See Also:
        Constant Field Values
      • publicIDs

        public LogicMetadataIDs publicIDs
        LM public IDs (admin, contract, datasets...) This field contains all IDs that must be the same even if we restart LM or for backups.
      • dcCredentials

        public PasswordCredential dcCredentials
        Credentials of DataClay registrator (for DataClay classes).
      • dbConf

        protected final T extends DBHandlerConf dbConf
        LogicModule read conf.
      • logicModuleHandler

        protected final SQLHandler<T extends DBHandlerConf> logicModuleHandler
        Logic Module database handler.
      • name

        protected String name
        Name of the LM
    • Constructor Detail

      • LogicModule

        public LogicModule​(String lmName,
                           String thehostname,
                           int theport,
                           String theexposedIPForClient)
                    throws InterruptedException
        LogicModule constructor
        Parameters:
        lmName - LM name
        thehostname - Logic module host name
        theport - Logic Module port.
        theexposedIPForClient - IPs to be send to clients when information of a registered EE/SL is required. Can be null.
        Throws:
        InterruptedException - If GRPC client cannot be initialized for some reason
    • Method Detail

      • initDBConf

        protected abstract T initDBConf()
        Initialize database configuration.
        Returns:
        Database configuration
      • initDBHandler

        protected abstract SQLHandler<T> initDBHandler()
        Initializes DB handler.
        Returns:
        DB handler.
      • getExecutionEnvironmentAPI

        public DataServiceAPI getExecutionEnvironmentAPI​(ExecutionEnvironment backend)
        Get remote DataService API
        Parameters:
        backend - Backend specification
        Returns:
        API of remote DS
        Throws:
        Exception - If DS not started
      • updateAPIsFromDB

        protected void updateAPIsFromDB()
        Update APIs for all registered environments/storage locations
      • cleanCachesOfDataService

        public void cleanCachesOfDataService​(String dsName)
        Resume traces in services
        Parameters:
        dsName - Name of the data service to be cleaned
        Throws:
        RemoteException - if exception occurs
      • publishAddress

        public void publishAddress​(String thehostname,
                                   int theport)
        Description copied from interface: LogicModuleAPI
        Configure LogicModule to give provided address in case external dataClays require to know how to access current dataClay
        Specified by:
        publishAddress in interface LogicModuleAPI
        Parameters:
        thehostname - Hostname to be published (given to external dataClays)
        theport - Port to be published
      • performSetOfNewAccounts

        public byte[] performSetOfNewAccounts​(AccountID adminID,
                                              PasswordCredential adminCredential,
                                              byte[] yamlFile)
        Description copied from interface: LogicModuleAPI
        Perform a series of new account creations, described by a YAML parameter.
        Specified by:
        performSetOfNewAccounts in interface LogicModuleAPI
        Parameters:
        adminID - ID of the account of the user that desires to perform the operations.
        adminCredential - Credential of the admin's account.
        yamlFile - A YAML file containing all the new users.
        Returns:
        A YAML file with the ID for the created users.
      • performSetOfOperations

        public byte[] performSetOfOperations​(AccountID performerID,
                                             PasswordCredential performerCredential,
                                             byte[] yamlFile)
        Description copied from interface: LogicModuleAPI
        Perform a series of operations, described by a YAML parameter.
        Specified by:
        performSetOfOperations in interface LogicModuleAPI
        Parameters:
        performerID - ID of the account of the user that desires to perform the operations.
        performerCredential - Credential of the performer's account.
        yamlFile - A YAML file containing all the operations.
        Returns:
        A YAML file with the result for all the operations.
      • newAccountNoAdmin

        public AccountID newAccountNoAdmin​(Account newAccount)
        Description copied from interface: LogicModuleAPI
        This operation creates a new account in the system without admin credentials.
        Specified by:
        newAccountNoAdmin in interface LogicModuleAPI
        Parameters:
        newAccount - Specifications of the account to create
        Returns:
        AccountID of the new account if the it was successfully created.
      • newAccount

        public AccountID newAccount​(AccountID adminAccountID,
                                    PasswordCredential adminCredential,
                                    Account newAccount)
        Description copied from interface: LogicModuleAPI
        This operation creates a new account in the system with the provided username.
        Specified by:
        newAccount in interface LogicModuleAPI
        Parameters:
        adminAccountID - ID of the account of the user that calls the operation
        adminCredential - Credential of the adminAccount provided
        newAccount - Specifications of the account to create
        Returns:
        AccountID of the new account if the it was successfully created.
      • getAccountID

        public AccountID getAccountID​(String accountName)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the id of an account given its name
        Specified by:
        getAccountID in interface LogicModuleAPI
        Parameters:
        accountName - the user name of the account
        Returns:
        the account id if the operation succeeds. null otherwise.
      • getAccountList

        public HashSet<AccountID> getAccountList​(AccountID adminAccountID,
                                                 PasswordCredential adminCredential)
        Description copied from interface: LogicModuleAPI
        The list of users registered in the system
        Specified by:
        getAccountList in interface LogicModuleAPI
        Parameters:
        adminAccountID - ID of the account of the user that calls the operation
        adminCredential - Credential of the adminAccount provided
        Returns:
        the IDs of the users registered in the system.
      • newSession

        public SessionInfo newSession​(AccountID accountID,
                                      PasswordCredential credential,
                                      Set<ContractID> contracts,
                                      Set<DataSetID> dataSetIDs,
                                      DataSetID dataSetForStore,
                                      CommonMessages.Langs newsessionLang)
        Description copied from interface: LogicModuleAPI
        Method that registeres a new session for the given account considering the provided interfaces in contract
        Specified by:
        newSession in interface LogicModuleAPI
        Parameters:
        accountID - ID of the account
        credential - credentials for the account
        contracts - contracts to be considered
        dataSetIDs - Accessible datasets for the session (user must have one data contract for each dataset)
        dataSetForStore - Dataset for store (dataset must be include among the dataSets)
        newsessionLang - language for the sesssion
        Returns:
        Information of the new session
      • newNamespace

        public NamespaceID newNamespace​(AccountID accountID,
                                        PasswordCredential credential,
                                        Namespace newNamespace)
        Description copied from interface: LogicModuleAPI
        Method that creates a new namespace in the system.
        Specified by:
        newNamespace in interface LogicModuleAPI
        Parameters:
        accountID - the account id of the account
        credential - the credential of the account
        newNamespace - Specifications of the new namespace
        Returns:
        the id of the new namespace
      • removeNamespace

        public void removeNamespace​(AccountID accountID,
                                    PasswordCredential credential,
                                    String namespaceName)
        Description copied from interface: LogicModuleAPI
        This method removes a namespace from the system by checking it has no active contract associated with it, and no classes registered on it.
        Specified by:
        removeNamespace in interface LogicModuleAPI
        Parameters:
        accountID - the account id either of the responsible of the namespace or the the admin account
        credential - the credential of the account
        namespaceName - the name of the namespace
      • getNamespaceID

        public NamespaceID getNamespaceID​(AccountID accountID,
                                          PasswordCredential credential,
                                          String namespaceName)
        Description copied from interface: LogicModuleAPI
        Retrieves the id of a namespace identified by name provided
        Specified by:
        getNamespaceID in interface LogicModuleAPI
        Parameters:
        accountID - Requester account id
        credential - Requester credential
        namespaceName - Name of the namespace
        Returns:
        ID of the namespace or NULL if an error happened.
      • getNamespaceLang

        public CommonMessages.Langs getNamespaceLang​(AccountID accountID,
                                                     PasswordCredential credential,
                                                     String namespaceName)
        Description copied from interface: LogicModuleAPI
        Retrieves the language of a namespace identified by name provided
        Specified by:
        getNamespaceLang in interface LogicModuleAPI
        Parameters:
        accountID - Requester account id
        credential - Requester credential
        namespaceName - Name of the namespace
        Returns:
        Language of the namespace or NULL if an error happened.
      • importInterface

        public void importInterface​(AccountID accountID,
                                    PasswordCredential credential,
                                    NamespaceID namespaceID,
                                    ContractID contractID,
                                    InterfaceID interfaceID)
        Description copied from interface: LogicModuleAPI
        Imports an interface in contract into a specific namespace
        Specified by:
        importInterface in interface LogicModuleAPI
        Parameters:
        accountID - the account that performs the action
        credential - credentials of the account
        namespaceID - ID of namespace where interface in contract is imported
        contractID - ID of the contract
        interfaceID - ID of the interface
      • importContract

        public void importContract​(AccountID accountID,
                                   PasswordCredential credential,
                                   NamespaceID namespaceID,
                                   ContractID contractID)
        Description copied from interface: LogicModuleAPI
        Imports the interfaces of the contract into a specific namespace
        Specified by:
        importContract in interface LogicModuleAPI
        Parameters:
        accountID - the account that performs the action
        credential - credentials of the account
        namespaceID - ID of namespace where interface in contract is imported
        contractID - ID of the contract
      • newDataSet

        public DataSetID newDataSet​(AccountID accountID,
                                    PasswordCredential credential,
                                    DataSet newDataSet)
        Description copied from interface: LogicModuleAPI
        Method that creates a new dataset in the system.
        Specified by:
        newDataSet in interface LogicModuleAPI
        Parameters:
        accountID - the account id of the account
        credential - the credential of the account
        newDataSet - Specifications of the dataset to create
        Returns:
        the id of the new dataset
      • removeDataSet

        public void removeDataSet​(AccountID accountID,
                                  PasswordCredential credential,
                                  String datasetName)
        Description copied from interface: LogicModuleAPI
        This method removes a dataset from the system by checking it has no active data contract associated with it and no objects registered in it.
        Specified by:
        removeDataSet in interface LogicModuleAPI
        Parameters:
        accountID - the account id either of the responsible of the dataset or the the admin account
        credential - the credential of the account
        datasetName - the name of the dataset
      • getDataSetID

        public DataSetID getDataSetID​(AccountID accountID,
                                      PasswordCredential credential,
                                      String datasetName)
        Description copied from interface: LogicModuleAPI
        Retrieves the id of a dataset identified by name provided
        Specified by:
        getDataSetID in interface LogicModuleAPI
        Parameters:
        accountID - ID of the account responsible of the given dataset
        credential - Credential of the account
        datasetName - Name of the dataset
        Returns:
        ID of the namespace or NULL if an error happened.
      • checkDataSetIsPublic

        public boolean checkDataSetIsPublic​(DataSetID datasetID)
        Description copied from interface: LogicModuleAPI
        Checks whether the dataset is public or not
        Specified by:
        checkDataSetIsPublic in interface LogicModuleAPI
        Parameters:
        datasetID - ID of the dataset to be chcecked
        Returns:
        true if the dataset is public, false otherwise.
      • getObjectDataSetID

        public DataSetID getObjectDataSetID​(SessionID sessionID,
                                            ObjectID oid)
        Description copied from interface: LogicModuleAPI
        Retrieves the id of a dataset of the object with ID provided.
        Specified by:
        getObjectDataSetID in interface LogicModuleAPI
        Parameters:
        sessionID - ID of session
        oid - Object ID
        Returns:
        ID of the dataset or NULL if an error happened.
      • newClass

        public Map<String,​MetaClass> newClass​(AccountID accountID,
                                                    PasswordCredential credential,
                                                    CommonMessages.Langs language,
                                                    Map<String,​MetaClass> newClasses)
        Description copied from interface: LogicModuleAPI
        This operation creates a new metaclass in the system with the provided specifications and associate it to the Namespace provided.
        Specified by:
        newClass in interface LogicModuleAPI
        Parameters:
        accountID - ID of the account of the user that calls the operation
        credential - Credential of the account provided
        language - Language of the classes provided
        newClasses - Specifications of classes to create
        Returns:
        info of the new MetaClass if it was successfully created.
      • newClassID

        public MetaClassID newClassID​(AccountID accountID,
                                      PasswordCredential credential,
                                      String className,
                                      CommonMessages.Langs language,
                                      Map<String,​MetaClass> newClasses)
        Description copied from interface: LogicModuleAPI
        This operation creates a new metaclass in the system with the provided specifications and associate it to the Namespace provided.
        Specified by:
        newClassID in interface LogicModuleAPI
        Parameters:
        accountID - ID of the account of the user that calls the operation
        credential - Credential of the account provided
        className - Name of the class from which to get ID
        language - Language of the classes provided
        newClasses - Specifications of classes to create
        Returns:
        metaClassID of the new MetaClass if it was successfully created.
      • registerAndUpdateDependencies

        public Map<String,​MetaClass> registerAndUpdateDependencies​(AccountID accountID,
                                                                         PasswordCredential credentials,
                                                                         CommonMessages.Langs language,
                                                                         Map<String,​MetaClass> metaClasses,
                                                                         NamespaceID enrichmentNamespaceID,
                                                                         String enrichedClassName)
        This internal operation recursively registers all the required dependencies of a metaClass to be usable.
        Parameters:
        accountID - ID of the account of the user that calls the operation
        credentials - Credentials of the account provided
        language - Language of the classes provided
        metaClasses - ifications of classes to create
        enrichmentNamespaceID - ID of the Namespace of the enrichment (can be NULL)
        enrichedClassName - if we are executing the method from en enrichment process, the name of the enriched class
        Returns:
        the id or information of the new metaclass if the operation succeeds. null otherwise.
        Throws:
        RemoteException - if some exception occurs
      • removeClass

        public void removeClass​(AccountID accountID,
                                PasswordCredential credential,
                                NamespaceID namespaceID,
                                String className)
        Description copied from interface: LogicModuleAPI
        Method that removes a class given its name and the name of the namespace where it belongs to
        Specified by:
        removeClass in interface LogicModuleAPI
        Parameters:
        accountID - ID of the account responsible of the namespace of the class
        credential - Credential of the account responsible of the namespace of the class
        namespaceID - ID of the namespace of the class to remove
        className - Name of the class to remove
      • removeOperation

        public void removeOperation​(AccountID accountID,
                                    PasswordCredential credential,
                                    NamespaceID namespaceID,
                                    String className,
                                    String operationSignature)
        Description copied from interface: LogicModuleAPI
        Method that removes an operation given its signature
        Specified by:
        removeOperation in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace
        credential - the credentials of the account
        namespaceID - the ID of the namespace of the class of the operation
        className - the name of the class of the opreation
        operationSignature - the signature of the operation
      • removeImplementation

        public void removeImplementation​(AccountID accountID,
                                         PasswordCredential credential,
                                         NamespaceID namespaceID,
                                         ImplementationID implementationID)
        Description copied from interface: LogicModuleAPI
        Method that removes an implementation of a certain operation
        Specified by:
        removeImplementation in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace
        credential - the credentials of the account
        namespaceID - ID of the namespace of the implementation
        implementationID - the id of the implementation
      • getOperationID

        public OperationID getOperationID​(AccountID accountID,
                                          PasswordCredential credential,
                                          NamespaceID namespaceID,
                                          String className,
                                          String operationSignature)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the id of an operation given its signature
        Specified by:
        getOperationID in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace
        credential - the credentials of the account
        namespaceID - the id of the namespace
        className - the name of the class
        operationSignature - signature of the operation
        Returns:
        the operation id if the operation succeeds. null otherwise.
      • getPropertyID

        public PropertyID getPropertyID​(AccountID accountID,
                                        PasswordCredential credential,
                                        NamespaceID namespaceID,
                                        String className,
                                        String propertyName)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the id of a property given its signature
        Specified by:
        getPropertyID in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace
        credential - the credentials of the account
        namespaceID - the id of the namespace
        className - the name of the class
        propertyName - the name of the property
        Returns:
        the property id if the operation succeeds. null otherwise.
      • getClassID

        public MetaClassID getClassID​(AccountID accountID,
                                      PasswordCredential credential,
                                      NamespaceID namespaceID,
                                      String className)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the id of a class given its name
        Specified by:
        getClassID in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace
        credential - the credentials of the account
        namespaceID - the id of the namespace
        className - the name of the class
        Returns:
        the class id if the operation succeeds. null otherwise.
      • getClassInfo

        public MetaClass getClassInfo​(AccountID accountID,
                                      PasswordCredential credential,
                                      NamespaceID namespaceID,
                                      String className)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the id of a class given its name
        Specified by:
        getClassInfo in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace
        credential - the credentials of the account
        namespaceID - the id of the namespace
        className - the name of the class
        Returns:
        the class id if the operation succeeds. null otherwise.
      • getInfoOfClassesInNamespace

        public Map<MetaClassID,​MetaClass> getInfoOfClassesInNamespace​(AccountID accountID,
                                                                            PasswordCredential credential,
                                                                            NamespaceID namespaceID)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the info of the classes registered in specific namespace.
        Specified by:
        getInfoOfClassesInNamespace in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace
        credential - the credentials of the account
        namespaceID - the id of the namespace
        Returns:
        The info of the classes registered in the given namespace if the operation succeeds. null otherwise.
      • newContract

        public ContractID newContract​(AccountID accountID,
                                      PasswordCredential credential,
                                      Contract newContract)
        Description copied from interface: LogicModuleAPI
        Method to register a new contract.
        Specified by:
        newContract in interface LogicModuleAPI
        Parameters:
        accountID - The account of the contract provider
        credential - Credential of the account
        newContract - the specification of the contract (dates, interfaces, etc.)
        Returns:
        the contract id if the operation succeeds. null otherwise.
      • registerToPublicContract

        public void registerToPublicContract​(AccountID accountID,
                                             PasswordCredential credential,
                                             ContractID contractID)
        Description copied from interface: LogicModuleAPI
        Method to register an account to a contract
        Specified by:
        registerToPublicContract in interface LogicModuleAPI
        Parameters:
        accountID - The account of the applicant for the contract
        credential - The credential of the applicant for the contract
        contractID - ID of the contract in which to register.
      • registerToPublicContractOfNamespace

        public ContractID registerToPublicContractOfNamespace​(AccountID accountID,
                                                              PasswordCredential credential,
                                                              NamespaceID namespaceID)
        Description copied from interface: LogicModuleAPI
        Method to register an account to a public contract given a namespace
        Specified by:
        registerToPublicContractOfNamespace in interface LogicModuleAPI
        Parameters:
        accountID - The account of the applicant for the contract
        credential - The credential of the applicant for the contract
        namespaceID - ID of the namespace in which to register (in case it provides a public contract)
        Returns:
        ID of the public contract associated with the namespace
      • getContractIDsOfProvider

        public Map<ContractID,​Contract> getContractIDsOfProvider​(AccountID accountID,
                                                                       PasswordCredential credential,
                                                                       NamespaceID namespaceIDofProvider)
        Description copied from interface: LogicModuleAPI
        Method that returns all contract IDs of a namespace (as provider).
        Specified by:
        getContractIDsOfProvider in interface LogicModuleAPI
        Parameters:
        accountID - ID of the responsible of the namespace.
        credential - credentails of the responsible of the namespace.
        namespaceIDofProvider - ID of the namespace provider
        Returns:
        A list of Contract IDs of the namespace as provider.
      • getContractIDsOfApplicant

        public Map<ContractID,​Contract> getContractIDsOfApplicant​(AccountID applicantAccountID,
                                                                        PasswordCredential credential)
        Description copied from interface: LogicModuleAPI
        Method that returns all contract IDs of a user (as applicant).
        Specified by:
        getContractIDsOfApplicant in interface LogicModuleAPI
        Parameters:
        applicantAccountID - Account ID of the user that queries for its contract IDs
        credential - Credential of the account
        Returns:
        A list of Contract IDs of the account provided.
      • getContractIDsOfApplicantWithProvider

        public Map<ContractID,​Contract> getContractIDsOfApplicantWithProvider​(AccountID applicantAccountID,
                                                                                    PasswordCredential credential,
                                                                                    NamespaceID namespaceIDofProvider)
        Description copied from interface: LogicModuleAPI
        Method that returns all contract IDs of a user (as applicant) with the given namespace provider.
        Specified by:
        getContractIDsOfApplicantWithProvider in interface LogicModuleAPI
        Parameters:
        applicantAccountID - Account ID of the user that queries for its contract IDs.
        credential - Credential of the account.
        namespaceIDofProvider - ID of the namespace that provides the contracts to be retrieved.
        Returns:
        A list of Contract IDs of the specified account with the given namespace provider.
      • newDataContract

        public DataContractID newDataContract​(AccountID accountID,
                                              PasswordCredential credential,
                                              DataContract newDataContract)
        Description copied from interface: LogicModuleAPI
        Creates a new Data Contract
        Specified by:
        newDataContract in interface LogicModuleAPI
        Parameters:
        accountID - ID of the responsible of the dataset
        credential - credential of the account responsible of dataset
        newDataContract - specifications of the datacontract to create
        Returns:
        The id of the new contract if it success, error otherwise.
      • registerToPublicDataContract

        public void registerToPublicDataContract​(AccountID accountID,
                                                 PasswordCredential credential,
                                                 DataContractID datacontractID)
        Description copied from interface: LogicModuleAPI
        Method that registers a certain account to a public data contract.
        Specified by:
        registerToPublicDataContract in interface LogicModuleAPI
        Parameters:
        accountID - ID of the account that wants to be registered to the contract
        credential - the credential of the acount
        datacontractID - the ID of the public data contract
      • getDataContractIDsOfProvider

        public Map<DataContractID,​DataContract> getDataContractIDsOfProvider​(AccountID accountID,
                                                                                   PasswordCredential credential,
                                                                                   DataSetID datasetIDofProvider)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the data contracts that a dataset provides.
        Specified by:
        getDataContractIDsOfProvider in interface LogicModuleAPI
        Parameters:
        accountID - ID of a responsible of the data contract (or admin)
        credential - credential of the account
        datasetIDofProvider - ID of the dataset providing the contracts
        Returns:
        The set of data contracts provided by the dataset.
      • getDataContractInfoOfApplicantWithProvider

        public DataContract getDataContractInfoOfApplicantWithProvider​(AccountID applicantAccountID,
                                                                       PasswordCredential credential,
                                                                       DataSetID datasetIDofProvider)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the data contract of an account (as applicant) with a certain dataset.
        Specified by:
        getDataContractInfoOfApplicantWithProvider in interface LogicModuleAPI
        Parameters:
        applicantAccountID - ID of the account to be checked.
        credential - credential of the account
        datasetIDofProvider - ID of the dataset as provider
        Returns:
        the data contract the account has applied to with the given dataset
      • newInterface

        public InterfaceID newInterface​(AccountID accountID,
                                        PasswordCredential credential,
                                        Interface newInterface)
        Description copied from interface: LogicModuleAPI
        Method that registers a new interface
        Specified by:
        newInterface in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace of the class
        credential - the credentials of the account
        newInterface - specifications of interface to create
        Returns:
        ID of the new interface created or NULL if it failed.
      • getInterfaceInfo

        public Interface getInterfaceInfo​(AccountID accountID,
                                          PasswordCredential credential,
                                          InterfaceID interfaceID)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the info of the interface if the account is registered in a contract that contains it
        Specified by:
        getInterfaceInfo in interface LogicModuleAPI
        Parameters:
        accountID - ID of the account registered in a contract with the interface present
        credential - the credential of the account
        interfaceID - the ID of the interface to be retrieved
        Returns:
        info of the interface
      • removeInterface

        public void removeInterface​(AccountID accountID,
                                    PasswordCredential credential,
                                    NamespaceID namespaceID,
                                    InterfaceID interfaceID)
        Description copied from interface: LogicModuleAPI
        Method that removes a specific interface
        Specified by:
        removeInterface in interface LogicModuleAPI
        Parameters:
        accountID - the account of the responsible of the namespace of the interface
        credential - the credentials of the acount
        namespaceID - ID of the namespace of the interface
        interfaceID - the id of the interface to be removed
      • unregisterObjects

        public void unregisterObjects​(Set<ObjectID> objectsToUnregister)
        Description copied from interface: LogicModuleAPI
        Unregister objects (called from GlobalGC)
        Specified by:
        unregisterObjects in interface LogicModuleAPI
        Parameters:
        objectsToUnregister - Objects to unregister
      • registerObjectFromGC

        public void registerObjectFromGC​(RegistrationInfo regInfo,
                                         ExecutionEnvironmentID backendID,
                                         DataServiceRuntime clientLib)
        Description copied from interface: LogicModuleAPI
        Register objects in MDS
        Specified by:
        registerObjectFromGC in interface LogicModuleAPI
        Parameters:
        regInfo - Registration info
        backendID - ID of the backend in which the objects were stored
        clientLib - DataService objects Map to be modified since this call is ASYNCHRONOUS. Thus, modified by GRPC (see Logic module grpc client)
      • getExecutionEnvironmentsInfo

        public Map<ExecutionEnvironmentID,​ExecutionEnvironment> getExecutionEnvironmentsInfo​(SessionID sessionID,
                                                                                                   CommonMessages.Langs execEnvLang,
                                                                                                   boolean fromClient)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the info of all the registered backends
        Specified by:
        getExecutionEnvironmentsInfo in interface LogicModuleAPI
        Parameters:
        sessionID - ID of session asking
        execEnvLang - Language of execution environments to get information of
        fromClient - Indicates information was requested from client
        Returns:
        the info of the registered Storage Locations in a table indexed by their IDs
      • getExecutionEnvironmentsNames

        public Set<String> getExecutionEnvironmentsNames​(AccountID accountID,
                                                         PasswordCredential credential,
                                                         CommonMessages.Langs execEnvLang)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the names of registered backends by language
        Specified by:
        getExecutionEnvironmentsNames in interface LogicModuleAPI
        Parameters:
        accountID - ID of account
        credential - credentials of the account
        execEnvLang - Language of exec environments.
        Returns:
        the info of the registered Storage Locations in a table indexed by their IDs
      • getObjectInfo

        public Tuple<String,​String> getObjectInfo​(SessionID sessionID,
                                                        ObjectID objectID)
        Description copied from interface: LogicModuleAPI
        Method to check whether an object is accessible with the specified session and returns its classname and namespace of the class.
        Specified by:
        getObjectInfo in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        objectID - ID of object
        Returns:
        a tuple [class name, namespace] containing the class of the object, and the namespace of the class.
      • deleteAlias

        public void deleteAlias​(SessionID sessionID,
                                String alias)
        Description copied from interface: LogicModuleAPI
        Removes the alias of an object
        Specified by:
        deleteAlias in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        alias - alias of the object
      • getExternalDataClayID

        public DataClayInstanceID getExternalDataClayID​(String dcHost,
                                                        int dcPort)
        Description copied from interface: LogicModuleAPI
        Tries to connect to an external dataClay instance and retrieve its ID. *
        Specified by:
        getExternalDataClayID in interface LogicModuleAPI
        Parameters:
        dcHost - hostname of the external dataClay instance
        dcPort - port of the external dataClay instance
        Returns:
        id of the external dataClay instance
      • getExternalDataClayInfo

        public DataClayInstance getExternalDataClayInfo​(DataClayInstanceID extDataClayID)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the info of an external dataClay instance
        Specified by:
        getExternalDataClayInfo in interface LogicModuleAPI
        Parameters:
        extDataClayID - id of the external (already registered) dataClay
        Returns:
        info of dataClay instance identified by specified ID. null if it is not registered in the system.
      • registerExternalDataClay

        public DataClayInstanceID registerExternalDataClay​(String thehostname,
                                                           int theport)
        Description copied from interface: LogicModuleAPI
        Method that tries to register an external instance of dataClay assigning a new ID to it. If if is already registered, method is ignored.
        Specified by:
        registerExternalDataClay in interface LogicModuleAPI
        Parameters:
        thehostname - host name of the main service of the external dataClay instance.
        theport - port of the external main service of the dataClay instance
        Returns:
        ID of dataClay registered.
      • registerExternalDataClayOverrideAuthority

        public DataClayInstanceID registerExternalDataClayOverrideAuthority​(AccountID adminAccountID,
                                                                            PasswordCredential adminCredential,
                                                                            String thehostname,
                                                                            int theport,
                                                                            String authority)
        Description copied from interface: LogicModuleAPI
        For system-admin users only. Method that registers an external dataclay overriding authority specified.
        Specified by:
        registerExternalDataClayOverrideAuthority in interface LogicModuleAPI
        Parameters:
        adminAccountID - Admin account iD
        adminCredential - Admin credentials
        thehostname - Hostname
        theport - Port
        authority - Authority
        Returns:
        ID of the dataClay registered
      • notifyRegistrationOfExternalDataClay

        public DataClayInstanceID notifyRegistrationOfExternalDataClay​(DataClayInstanceID dataClayInstanceID,
                                                                       String thehostname,
                                                                       int theport)
        Description copied from interface: LogicModuleAPI
        When you register an external DataClay, we notify external dataClay about the registration and we get the ID of the external dataClay. Destination dataClay then, is aware of all dataClays 'connected' to him.
        Specified by:
        notifyRegistrationOfExternalDataClay in interface LogicModuleAPI
        Parameters:
        dataClayInstanceID - ID of dataClay registering current dataClay as external
        thehostname - Host name
        theport - Port
        Returns:
        ID of current dataClay or Null if not allowed or some error ocurred
      • federateObject

        public void federateObject​(SessionID sessionID,
                                   ObjectID objectID,
                                   DataClayInstanceID extDataClayID,
                                   boolean recursive)
        Description copied from interface: LogicModuleAPI
        Method that federates an object with an external dataClay instance
        Specified by:
        federateObject in interface LogicModuleAPI
        Parameters:
        sessionID - id of the current session
        objectID - id of the object to be federated
        extDataClayID - ID of the external dataClay instance
        recursive - whether subobjects should be also federated or not
      • checkObjectIsFederatedWithDataClayInstance

        public boolean checkObjectIsFederatedWithDataClayInstance​(ObjectID objectID,
                                                                  DataClayInstanceID extDataClayID)
        Description copied from interface: LogicModuleAPI
        Checks if the given object is federated with given external dataClay instance
        Specified by:
        checkObjectIsFederatedWithDataClayInstance in interface LogicModuleAPI
        Parameters:
        objectID - id of the object
        extDataClayID - id of the dataClay instance
        Returns:
        TRUE if the object is federated with the given external dataClay instance. FALSE otherwise.
      • unfederateObject

        public void unfederateObject​(SessionID sessionID,
                                     ObjectID objectID,
                                     DataClayInstanceID extDataClayID,
                                     boolean recursive)
        Description copied from interface: LogicModuleAPI
        Method that unfederates an object
        Specified by:
        unfederateObject in interface LogicModuleAPI
        Parameters:
        sessionID - id of the current session
        objectID - id of the object to be unfederated
        extDataClayID - ID of the external dataClay to unfederate the object with.
        recursive - whether subobjects should be also unfederated or not
      • unfederateObjectWithAllDCs

        public void unfederateObjectWithAllDCs​(SessionID sessionID,
                                               ObjectID objectID,
                                               boolean recursive)
        Description copied from interface: LogicModuleAPI
        Method that unfederates a concrete object belonging/shared with ANY external dataClay provided.
        Specified by:
        unfederateObjectWithAllDCs in interface LogicModuleAPI
        Parameters:
        sessionID - id of the current session
        objectID - id of the object to unfederate with all DCs
        recursive - Indicates to unfederate all sub-objects with any external dataClay also.
      • unfederateAllObjects

        public void unfederateAllObjects​(SessionID sessionID,
                                         DataClayInstanceID extDataClayID)
        Description copied from interface: LogicModuleAPI
        Method that unfederates all objects belonging/shared with external dataClay provided.
        Specified by:
        unfederateAllObjects in interface LogicModuleAPI
        Parameters:
        sessionID - id of the current session
        extDataClayID - ID of the external dataClay to unfederate the object with.
      • unfederateAllObjectsWithAllDCs

        public void unfederateAllObjectsWithAllDCs​(SessionID sessionID)
        Description copied from interface: LogicModuleAPI
        Method that unfederates all objects belonging/shared with ANY external dataClay provided.
        Specified by:
        unfederateAllObjectsWithAllDCs in interface LogicModuleAPI
        Parameters:
        sessionID - id of the current session
      • migrateFederatedObjects

        public void migrateFederatedObjects​(SessionID sessionID,
                                            DataClayInstanceID externalOriginDataClayID,
                                            DataClayInstanceID externalDestinationDataClayID)
        Description copied from interface: LogicModuleAPI
        Method that moves all objects (belonging to current dataClay) and federated TO a certain external dataClay to another external dataClay.
        Specified by:
        migrateFederatedObjects in interface LogicModuleAPI
        Parameters:
        sessionID - id of the current session
        externalOriginDataClayID - ID of external dataClay objects are federated to
        externalDestinationDataClayID - ID of external dataClay to federated the objects
      • federateAllObjects

        public void federateAllObjects​(SessionID sessionID,
                                       DataClayInstanceID externalDestinationDataClayID)
        Description copied from interface: LogicModuleAPI
        Federate all objects belonging to current dataClay with external dataClay provided
        Specified by:
        federateAllObjects in interface LogicModuleAPI
        Parameters:
        sessionID - id of the current session
        externalDestinationDataClayID - ID of external dataClay to federated the objects
      • notifyUnfederatedObjects

        public void notifyUnfederatedObjects​(DataClayInstanceID srcDataClayID,
                                             Set<ObjectID> objectsIDs)
        Description copied from interface: LogicModuleAPI
        Method that notifies current dataClay instance to unfederate objects with source dataclay provided.
        Specified by:
        notifyUnfederatedObjects in interface LogicModuleAPI
        Parameters:
        srcDataClayID - id of source dataClay instance
        objectsIDs - ids of objects to federate
      • newVersion

        public VersionInfo newVersion​(SessionID sessionID,
                                      ObjectID objectID,
                                      ExecutionEnvironmentID optionalDestBackendID)
        Description copied from interface: LogicModuleAPI
        Method that creates a persistent new version of the object. If a destination backend is given, it tries to store the object in it.
        Specified by:
        newVersion in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        objectID - ID of the object
        optionalDestBackendID - optionally a preferred destination backend
        Returns:
        the information about the new version required for consolidate
      • consolidateVersion

        public void consolidateVersion​(SessionID sessionID,
                                       VersionInfo version)
        Description copied from interface: LogicModuleAPI
        Makes the object with finalVersionID the definitive version of the object with originalObjectID. The original version is deleted.
        Specified by:
        consolidateVersion in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        version - Info about the version containing ID of the root of the version and mapping versionID-originalID for all the versioned objects
      • newReplica

        public ExecutionEnvironmentID newReplica​(SessionID sessionID,
                                                 ObjectID objectID,
                                                 ExecutionEnvironmentID optionalDestBackendID,
                                                 boolean recursive)
        Description copied from interface: LogicModuleAPI
        Method that creates a new replica of the object. If a destination backend is given, it tries to replicate the object in it.
        Specified by:
        newReplica in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        objectID - ID of the object
        optionalDestBackendID - optionally a preferred destination backend
        recursive - Indicates if sub-objects must be also replicated or not.
        Returns:
        ID of the backend where replica has been eventually registered.
      • moveObject

        public List<ObjectID> moveObject​(SessionID sessionID,
                                         ObjectID objectID,
                                         ExecutionEnvironmentID srcLocationID,
                                         ExecutionEnvironmentID destLocationID,
                                         boolean recursive)
        Description copied from interface: LogicModuleAPI
        Method that moves an object from location to location.
        Specified by:
        moveObject in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        objectID - ID of the object
        srcLocationID - ID of the source location
        destLocationID - ID of the destination location
        recursive - Indicates if sub-objects (int the src location or others) must be also moved or not.
        Returns:
        List of moved objects.
      • setObjectReadOnly

        public void setObjectReadOnly​(SessionID sessionID,
                                      ObjectID objectID)
        Description copied from interface: LogicModuleAPI
        Method that sets the object as read only
        Specified by:
        setObjectReadOnly in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        objectID - ID of the object
      • setObjectReadWrite

        public void setObjectReadWrite​(SessionID sessionID,
                                       ObjectID objectID)
        Description copied from interface: LogicModuleAPI
        Method that sets the object as read-write
        Specified by:
        setObjectReadWrite in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        objectID - ID of the object
      • getMetadataByOID

        public MetaDataInfo getMetadataByOID​(SessionID sessionID,
                                             ObjectID objectID)
        Description copied from interface: LogicModuleAPI
        Method that retrieves the locations of all the replicas of a specific object and its classname.
        Specified by:
        getMetadataByOID in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session
        objectID - ID of the object
        Returns:
        MetaDataInfo of the object
      • getMetadataByOIDForDS

        public MetaDataInfo getMetadataByOIDForDS​(ObjectID objectID)
        Description copied from interface: LogicModuleAPI
        Get metadata by oid. TODO: functions without session ids (garbage collector for isntance) should be used in different way (dgasull)
        Specified by:
        getMetadataByOIDForDS in interface LogicModuleAPI
        Parameters:
        objectID - Object ID
        Returns:
        Metadata info for EE.
      • executeMethodOnTarget

        public SerializedParametersOrReturn executeMethodOnTarget​(SessionID sessionID,
                                                                  ObjectID objectID,
                                                                  String operationSignature,
                                                                  SerializedParametersOrReturn params,
                                                                  ExecutionEnvironmentID backendID)
        Description copied from interface: LogicModuleAPI
        Method that executes a method on a specific target (using an arbitrary implementation given the session info).
        Specified by:
        executeMethodOnTarget in interface LogicModuleAPI
        Parameters:
        sessionID - ID of the session.
        objectID - ID of the object on which the implementation is executed
        operationSignature - the operation signature of the method to be executed
        params - the serialized parameters for the method
        backendID - the backend where the method must be executed
        Returns:
        Result of the operation (all objects serialized) or null if void.
      • synchronizeFederatedObject

        public void synchronizeFederatedObject​(DataClayInstanceID extDataClayID,
                                               ObjectID objectID,
                                               ImplementationID implID,
                                               SerializedParametersOrReturn params,
                                               boolean allBackends)
        Description copied from interface: LogicModuleAPI
        Method that allows an external dataClay instance to request the execution of an implementation on a given object. This object must be a valid object shared with such an external dataClay.
        Specified by:
        synchronizeFederatedObject in interface LogicModuleAPI
        Parameters:
        extDataClayID - id of the external dataClay instance
        objectID - id of the target object
        implID - ID of the implementation to be executed
        params - parameters for the execution
        allBackends - Indicates if execution must be done in all replicas
      • getDataClaysObjectIsFederatedWith

        public Set<DataClayInstanceID> getDataClaysObjectIsFederatedWith​(ObjectID objectID)
        Description copied from interface: LogicModuleAPI
        Retrieve external dataClays which the given object has been federated with.
        Specified by:
        getDataClaysObjectIsFederatedWith in interface LogicModuleAPI
        Parameters:
        objectID - id of the federated object to be checked
        Returns:
        known dataClay instances having this federated object
      • executeNotificationAction

        public void executeNotificationAction​(ObjectID objectID,
                                              SessionID sessionID,
                                              SerializedParametersOrReturn params,
                                              OperationID opID)
        Method that executes an action in a certain object. This method is called from notification manager. Note that executions from this method have NO session.
        Parameters:
        objectID - ID of the object
        sessionID - ID of the session of who triggered action
        params - the serialized parameters for the operation
        opID - id of the operation to be executed
      • executeFilterMethod

        public boolean executeFilterMethod​(ObjectID objectID,
                                           SessionID sessionID,
                                           SerializedParametersOrReturn params,
                                           OperationID opID)
        Method that executes a filterMethod in a certain object without parameters. This method is called from notification manager. Note that executions from this method have NO session.
        Parameters:
        objectID - ID of the object
        sessionID - ID of the session of who triggered action
        params - the serialized parameters for the operation
        opID - id of the operation to be executed
        Returns:
        a boolean value with the result of the execution of the implementation (all of them, separately)
      • isPrefetchingEnabled

        public boolean isPrefetchingEnabled()
        Description copied from interface: LogicModuleAPI
        Indicates if dataClay has prefetching enabled.
        Specified by:
        isPrefetchingEnabled in interface LogicModuleAPI
        Returns:
        TRUE if prefetching is enabled in dataClay. FALSE otherwise.
      • objectExistsInDataClay

        public boolean objectExistsInDataClay​(ObjectID objectID)
        Description copied from interface: LogicModuleAPI
        Check if object exists in dataClay (in any EE memory or SL)
        Specified by:
        objectExistsInDataClay in interface LogicModuleAPI
        Parameters:
        objectID - ID of the object to check
        Returns:
        TRUE if the object exists. FALSE otherwise.
      • getOwner

        public AccountID getOwner​(ObjectID objectID)
        Get owner of the object
        Parameters:
        objectID - ID of the object
        Returns:
        Owner of the object
      • initializeSessionAsOwnerOfObject

        public SessionID initializeSessionAsOwnerOfObject​(AccountID ownerID)
        Initialize session of owner's object.
        Parameters:
        ownerID - ID of the owner.
        Returns:
        Session ID
      • getStubs

        public Map<String,​byte[]> getStubs​(AccountID applicantAccountID,
                                                 PasswordCredential applicantCredential,
                                                 CommonMessages.Langs language,
                                                 List<ContractID> contractsIDs)
        Description copied from interface: LogicModuleAPI
        Method that allows to retrieve the stubs of the given contracts (merging interfaces if necessary)
        Specified by:
        getStubs in interface LogicModuleAPI
        Parameters:
        applicantAccountID - the applicant of the contract
        applicantCredential - the credentials of the applicant
        language - the language of the stub to generate
        contractsIDs - IDs of the contracts
        Returns:
        a Map of byte arrays with bytecode (or similar) for each stub
      • getBabelStubs

        public byte[] getBabelStubs​(AccountID applicantAccountID,
                                    PasswordCredential applicantCredential,
                                    List<ContractID> contractsIDs)
        Description copied from interface: LogicModuleAPI
        Method that allows to retrieve the "Babel" (language independent YAML-based) stubs of the given contracts (merging interfaces if necessary).
        Specified by:
        getBabelStubs in interface LogicModuleAPI
        Parameters:
        applicantAccountID - the applicant of the contract
        applicantCredential - the credentials of the applicant
        contractsIDs - IDs of the contracts
        Returns:
        a byte array with a YAML document, with each
      • registerEventListenerImplementation

        public void registerEventListenerImplementation​(AccountID accountID,
                                                        PasswordCredential credential,
                                                        ECA newEventListener)
        Description copied from interface: LogicModuleAPI
        Registers an event listener implementation
        Specified by:
        registerEventListenerImplementation in interface LogicModuleAPI
        Parameters:
        accountID - ID of account registering the event listener
        credential - Credentials of the account
        newEventListener - Event listener implementation to register.
      • adviseEvent

        public void adviseEvent​(EventMessage newEvent)
        Description copied from interface: LogicModuleAPI
        Advises Notification Manager new event has occurred.
        Specified by:
        adviseEvent in interface LogicModuleAPI
        Parameters:
        newEvent - New event
      • getMetaDataSrvApi

        public MetaDataService getMetaDataSrvApi()
        Returns:
        the metaDataSrvApi
      • activateTracing

        public void activateTracing​(int currentAvailableTaskID)
        Description copied from interface: LogicModuleAPI
        Activate tracing.
        Specified by:
        activateTracing in interface LogicModuleAPI
        Parameters:
        currentAvailableTaskID - Current starting task ID in Extrae
      • getTraces

        public Map<String,​byte[]> getTraces()
        Description copied from interface: LogicModuleAPI
        Get Extrae traces (mpits and set files)
        Specified by:
        getTraces in interface LogicModuleAPI
        Returns:
        Extrae traces (mpits and set files)
      • waitAndProcessAllAsyncRequests

        public void waitAndProcessAllAsyncRequests()
        Wait for all asynchronous request to finish.
      • finishCacheThreads

        public void finishCacheThreads()
        Finish cache threads.
      • getAccountManagerDB

        public AccountManagerDB getAccountManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getClassManagerDB

        public ClassManagerDB getClassManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getContractManagerDB

        public ContractManagerDB getContractManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getDataContractManagerDB

        public DataContractManagerDB getDataContractManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getDataSetManagerDB

        public DataSetManagerDB getDataSetManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getNamespaceManagerDB

        public NamespaceManagerDB getNamespaceManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getInterfaceManagerDB

        public InterfaceManagerDB getInterfaceManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getNotificationManagerDB

        public NotificationManagerDB getNotificationManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getSessionManagerDB

        public SessionManagerDB getSessionManagerDB()
        Get manager db. For testing purposes.
        Returns:
        Manager db.
      • getMetaDataServiceDb

        public MetaDataServiceDB getMetaDataServiceDb()
        Get logic db. For testing purposes.
        Returns:
        metadataservice db.
      • getClassManager

        public ClassManager getClassManager()
        Get Class manager (for testing purposes)
        Returns:
        ClassManager of this logicModule
      • isShuttingDown

        public boolean isShuttingDown()
        Returns:
        the shuttingDown
      • setShuttingDown

        public void setShuttingDown​(boolean theshuttingDown)
        Parameters:
        theshuttingDown - the shuttingDown to set
      • getDbHandler

        public DBHandler getDbHandler()
        For testing purposes.
        Returns:
        DBHandler of this LM.