@ -14,15 +14,9 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License .
* limitations under the License .
* /
* /
package org.apache.dolphinscheduler.server.master.runner ;
import java.util.concurrent.ThreadPoolExecutor ;
package org.apache.dolphinscheduler.server.master.runner ;
import java.util.concurrent.TimeUnit ;
import javax.annotation.PostConstruct ;
import org.apache.curator.framework.imps.CuratorFrameworkState ;
import org.apache.curator.framework.recipes.locks.InterProcessMutex ;
import org.apache.dolphinscheduler.common.Constants ;
import org.apache.dolphinscheduler.common.Constants ;
import org.apache.dolphinscheduler.common.thread.Stopper ;
import org.apache.dolphinscheduler.common.thread.Stopper ;
import org.apache.dolphinscheduler.common.thread.ThreadUtils ;
import org.apache.dolphinscheduler.common.thread.ThreadUtils ;
@ -36,6 +30,15 @@ import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.server.utils.AlertManager ;
import org.apache.dolphinscheduler.server.utils.AlertManager ;
import org.apache.dolphinscheduler.server.zk.ZKMasterClient ;
import org.apache.dolphinscheduler.server.zk.ZKMasterClient ;
import org.apache.dolphinscheduler.service.process.ProcessService ;
import org.apache.dolphinscheduler.service.process.ProcessService ;
import org.apache.curator.framework.imps.CuratorFrameworkState ;
import org.apache.curator.framework.recipes.locks.InterProcessMutex ;
import java.util.concurrent.ThreadPoolExecutor ;
import java.util.concurrent.TimeUnit ;
import javax.annotation.PostConstruct ;
import org.slf4j.Logger ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.slf4j.LoggerFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -90,14 +93,14 @@ public class MasterSchedulerService extends Thread {
* constructor of MasterSchedulerService
* constructor of MasterSchedulerService
* /
* /
@PostConstruct
@PostConstruct
public void init ( ) {
public void init ( ) {
this . masterExecService = ( ThreadPoolExecutor ) ThreadUtils . newDaemonFixedThreadExecutor ( "Master-Exec-Thread" , masterConfig . getMasterExecThreads ( ) ) ;
this . masterExecService = ( ThreadPoolExecutor ) ThreadUtils . newDaemonFixedThreadExecutor ( "Master-Exec-Thread" , masterConfig . getMasterExecThreads ( ) ) ;
NettyClientConfig clientConfig = new NettyClientConfig ( ) ;
NettyClientConfig clientConfig = new NettyClientConfig ( ) ;
this . nettyRemotingClient = new NettyRemotingClient ( clientConfig ) ;
this . nettyRemotingClient = new NettyRemotingClient ( clientConfig ) ;
}
}
@Override
@Override
public synchronized void start ( ) {
public synchronized void start ( ) {
super . setName ( "MasterSchedulerService" ) ;
super . setName ( "MasterSchedulerService" ) ;
super . start ( ) ;
super . start ( ) ;
}
}
@ -110,7 +113,7 @@ public class MasterSchedulerService extends Thread {
} catch ( InterruptedException ignore ) {
} catch ( InterruptedException ignore ) {
Thread . currentThread ( ) . interrupt ( ) ;
Thread . currentThread ( ) . interrupt ( ) ;
}
}
if ( ! terminated ) {
if ( ! terminated ) {
logger . warn ( "masterExecService shutdown without terminated, increase await time" ) ;
logger . warn ( "masterExecService shutdown without terminated, increase await time" ) ;
}
}
nettyRemotingClient . close ( ) ;
nettyRemotingClient . close ( ) ;
@ -123,7 +126,7 @@ public class MasterSchedulerService extends Thread {
@Override
@Override
public void run ( ) {
public void run ( ) {
logger . info ( "master scheduler started" ) ;
logger . info ( "master scheduler started" ) ;
while ( Stopper . isRunning ( ) ) {
while ( Stopper . isRunning ( ) ) {
try {
try {
boolean runCheckFlag = OSUtils . checkResource ( masterConfig . getMasterMaxCpuloadAvg ( ) , masterConfig . getMasterReservedMemory ( ) ) ;
boolean runCheckFlag = OSUtils . checkResource ( masterConfig . getMasterMaxCpuloadAvg ( ) , masterConfig . getMasterReservedMemory ( ) ) ;
if ( ! runCheckFlag ) {
if ( ! runCheckFlag ) {