Details

      Description

      Steps to reproduce
      1) enable clustering cluster.link.enabled=true
      2) unzip sample-scheduler-portlet into liferay sdk
      2) open up sample scheduler liferay-portlet.xml and set the time to be 3 min in the future (enough time to get through the deployment
      3) build and deploy the sample scheduler portlet (you may need to comment out license=ee requirement in plugin-package-properties)
      4) confirm that at the designated time, the job executes by printing out a message to the log
      5) use script to change between slave and master

      for master you have to set up a cluster with two nodes and have the nodes change between master and slave by taking them down and up again
      if you are using an IDE and a breakpoint to call initMemoryClusterJobs() before the scheduled jobs are deleted in ClusterSchedulerEngine then you can use the following script

      import com.liferay.portal.kernel.cluster.ClusterMasterExecutorUtil
      
      executor = ClusterMasterExecutorUtil.getClusterMasterExecutor()
      
      executor.notifyMasterTokenTransitionListeners(false)
      executor.notifyMasterTokenTransitionListeners(true)
      

      script for 6.2

      import java.lang.reflect.Proxy
      import com.liferay.portal.kernel.scheduler.SchedulerEngineHelperUtil
      import com.liferay.portal.messaging.proxy.MessagingProxyInvocationHandler
      import com.liferay.portal.scheduler.ClusterSchedulerEngine
      import com.liferay.portal.spring.aop.ServiceBeanAopProxy
      
      schedulerEngine = SchedulerEngineHelperUtil.getSchedulerEngineHelper()._schedulerEngine
      
      while (schedulerEngine.getClass() != ClusterSchedulerEngine.class) {
      	invocationHandler = Proxy.getInvocationHandler(schedulerEngine)
      
      	if (invocationHandler instanceof ServiceBeanAopProxy) {
      		schedulerEngine = invocationHandler._advisedSupport.getTargetSource().getTarget()
      	}
      	else {
      		println "Failed to unwrap class: " + invocationHandler.getClass()
      		break
      	}
      }
      
      if (schedulerEngine.getClass() == ClusterSchedulerEngine.class) {
      	masterAddressString = schedulerEngine.getMasterAddressString(false)
      
      	schedulerEngine.masterToSlave(masterAddressString, false)
      
      	println "Switched from master to slave"
      
      	schedulerEngine.slaveToMaster()
      
      	println "Switched from slave to master"
      }
      

      Expected behavior: since the job has already been run, there should not be any additional messages in the log saying that a job has been executed
      Actual behavior: a new message prints in the log indicating that a new job has been executed

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                brian.chan Brian Chan
                Reporter:
                andrew.betts Andrew Betts
                Participants of an Issue:
                Recent user:
                Sharry Shi
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 4 weeks, 2 days ago

                  Packages

                  Version Package
                  6.2.X EE