示例#1
0
 def __refreshAndPublish(self):
     self.__lastUpdateTime = time.time()
     gLogger.info("Refreshing from master server")
     from DIRAC.Core.DISET.RPCClient import RPCClient
     sMasterServer = gConfigurationData.getMasterServer()
     if sMasterServer:
         oClient = RPCClient(
             sMasterServer,
             timeout=self.__timeout,
             useCertificates=gConfigurationData.useServerCertificate(),
             skipCACheck=gConfigurationData.skipCACheck())
         dRetVal = _updateFromRemoteLocation(oClient)
         if not dRetVal['OK']:
             gLogger.error("Can't update from master server",
                           dRetVal['Message'])
             return False
         if gConfigurationData.getAutoPublish():
             gLogger.info("Publishing to master server...")
             dRetVal = oClient.publishSlaveServer(self.__url)
             if not dRetVal['OK']:
                 gLogger.error("Can't publish to master server",
                               dRetVal['Message'])
         return True
     else:
         gLogger.warn(
             "No master server is specified in the configuration, trying to get data from other slaves"
         )
         return self.__refresh()['OK']
示例#2
0
    def __refreshAndPublish(self):
        self.__lastUpdateTime = time.time()
        gLogger.info("Refreshing from master server")
        from DIRAC.Core.DISET.RPCClient import RPCClient

        sMasterServer = gConfigurationData.getMasterServer()
        if sMasterServer:
            oClient = RPCClient(
                sMasterServer,
                timeout=self.__timeout,
                useCertificates=gConfigurationData.useServerCertificate(),
                skipCACheck=gConfigurationData.skipCACheck(),
            )
            dRetVal = _updateFromRemoteLocation(oClient)
            if not dRetVal["OK"]:
                gLogger.error("Can't update from master server", dRetVal["Message"])
                return False
            if gConfigurationData.getAutoPublish():
                gLogger.info("Publishing to master server...")
                dRetVal = oClient.publishSlaveServer(self.__url)
                if not dRetVal["OK"]:
                    gLogger.error("Can't publish to master server", dRetVal["Message"])
            return True
        else:
            gLogger.warn("No master server is specified in the configuration, trying to get data from other slaves")
            return self.__refresh()["OK"]
示例#3
0
    def _refreshAndPublish(self):
        """
        Refresh configuration and publish local updates
        """
        self._lastUpdateTime = time.time()
        gLogger.info("Refreshing from master server")
        sMasterServer = gConfigurationData.getMasterServer()
        if sMasterServer:
            from DIRAC.ConfigurationSystem.Client.ConfigurationClient import ConfigurationClient

            oClient = ConfigurationClient(
                url=sMasterServer,
                timeout=self._timeout,
                useCertificates=gConfigurationData.useServerCertificate(),
                skipCACheck=gConfigurationData.skipCACheck(),
            )
            dRetVal = _updateFromRemoteLocation(oClient)
            if not dRetVal["OK"]:
                gLogger.error("Can't update from master server",
                              dRetVal["Message"])
                return False
            if gConfigurationData.getAutoPublish():
                gLogger.info("Publishing to master server...")
                dRetVal = oClient.publishSlaveServer(self._url)
                if not dRetVal["OK"]:
                    gLogger.error("Can't publish to master server",
                                  dRetVal["Message"])
            return True
        else:
            gLogger.warn(
                "No master server is specified in the configuration, trying to get data from other slaves"
            )
            return self._refresh()["OK"]
示例#4
0
 def autoRefreshAndPublish( self, sURL ):
   gLogger.debug( "Setting configuration refresh as automatic" )
   if not gConfigurationData.getAutoPublish():
     gLogger.debug( "Slave server won't auto publish itself" )
   if not gConfigurationData.getName():
     import DIRAC
     DIRAC.abort( 10, "Missing configuration name!" )
   self.__url = sURL
   self.__automaticUpdate = True
   self.setDaemon( 1 )
   self.start()
示例#5
0
 def autoRefreshAndPublish(self, sURL):
     gLogger.debug("Setting configuration refresh as automatic")
     if not gConfigurationData.getAutoPublish():
         gLogger.debug("Slave server won't auto publish itself")
     if not gConfigurationData.getName():
         import DIRAC
         DIRAC.abort(10, "Missing configuration name!")
     self.__url = sURL
     self.__automaticUpdate = True
     self.setDaemon(1)
     self.start()
示例#6
0
  def autoRefreshAndPublish(self, sURL):
    """
      Start the autorefresh background task

      :param str sURL: URL of the configuration server
    """
    gLogger.debug("Setting configuration refresh as automatic")
    if not gConfigurationData.getAutoPublish():
      gLogger.debug("Slave server won't auto publish itself")
    if not gConfigurationData.getName():
      import DIRAC
      DIRAC.abort(10, "Missing configuration name!")
    self._url = sURL
    self._automaticUpdate = True
    self.setDaemon(1)
    self.start()
示例#7
0
    def autoRefreshAndPublish(self, sURL):
        """
        Start the autorefresh background task, called by ServiceInterface
        (the class behind the Configuration/Server handler)

        :param str sURL: URL of the configuration server
        """
        gLogger.debug("Setting configuration refresh as automatic")
        if not gConfigurationData.getAutoPublish():
            gLogger.debug("Slave server won't auto publish itself")
        if not gConfigurationData.getName():
            import DIRAC

            DIRAC.abort(10, "Missing configuration name!")
        self._url = sURL
        self._automaticUpdate = True

        # Tornado replacement solution to the classic thread
        # It start the method self.__refreshLoop on the next IOLoop iteration
        _IOLoop.current().spawn_callback(self.__refreshLoop)