You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by qi...@apache.org on 2021/03/31 06:40:08 UTC

[shardingsphere-elasticjob] branch master updated: add static sharding strategy

This is an automated email from the ASF dual-hosted git repository.

qiulu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new ff6d7dd  add static sharding strategy
     new ae0249f  Merge pull request #1863 from Lucas-307/0330.1618
ff6d7dd is described below

commit ff6d7ddfde87b796a044002f92761474005597d8
Author: qiulu3 <Lucas209910>
AuthorDate: Wed Mar 31 14:38:43 2021 +0800

    add static sharding strategy
---
 .../elasticjob/api/JobConfiguration.java           | 33 +++++++++++++++++++++-
 .../infra/pojo/JobConfigurationPOJO.java           |  6 ++++
 .../infra/pojo/JobConfigurationPOJOTest.java       |  6 ++--
 .../lite/internal/reconcile/ReconcileService.java  | 17 ++++++++++-
 .../internal/sharding/ShardingListenerManager.java | 20 +++++++++++--
 .../internal/reconcile/ReconcileServiceTest.java   | 20 ++++++++++++-
 .../sharding/ShardingListenerManagerTest.java      | 25 ++++++++++++++--
 .../lifecycle/fixture/LifecycleYamlConstants.java  |  3 +-
 .../job/parser/JobBeanDefinitionParser.java        |  2 ++
 .../namespace/job/tag/JobBeanDefinitionTag.java    |  4 +++
 .../resources/META-INF/namespace/elasticjob.xsd    |  2 ++
 11 files changed, 128 insertions(+), 10 deletions(-)

diff --git a/elasticjob-api/src/main/java/org/apache/shardingsphere/elasticjob/api/JobConfiguration.java b/elasticjob-api/src/main/java/org/apache/shardingsphere/elasticjob/api/JobConfiguration.java
index 5d5dbd8..d927a93 100644
--- a/elasticjob-api/src/main/java/org/apache/shardingsphere/elasticjob/api/JobConfiguration.java
+++ b/elasticjob-api/src/main/java/org/apache/shardingsphere/elasticjob/api/JobConfiguration.java
@@ -75,6 +75,10 @@ public final class JobConfiguration {
     
     private final boolean overwrite;
     
+    private final String label;
+    
+    private final boolean staticSharding;
+    
     /**
      * Create ElasticJob configuration builder.
      *
@@ -127,6 +131,10 @@ public final class JobConfiguration {
         
         private boolean overwrite;
     
+        private String label;
+        
+        private boolean staticSharding;
+    
         /**
          * Cron expression.
          *
@@ -367,6 +375,28 @@ public final class JobConfiguration {
         }
         
         /**
+         * Set label.
+         *
+         * @param label label
+         * @return ElasticJob configuration builder
+         */
+        public Builder label(final String label) {
+            this.label = label;
+            return this;
+        }
+        
+        /**
+         * Set static sharding.
+         *
+         * @param staticSharding static sharding
+         * @return ElasticJob configuration builder
+         */
+        public Builder staticSharding(final boolean staticSharding) {
+            this.staticSharding = staticSharding;
+            return this;
+        }
+        
+        /**
          * Build ElasticJob configuration.
          * 
          * @return ElasticJob configuration
@@ -376,7 +406,8 @@ public final class JobConfiguration {
             Preconditions.checkArgument(shardingTotalCount > 0, "shardingTotalCount should larger than zero.");
             return new JobConfiguration(jobName, cron, shardingTotalCount, shardingItemParameters, jobParameter, 
                     monitorExecution, failover, misfire, maxTimeDiffSeconds, reconcileIntervalMinutes,
-                    jobShardingStrategyType, jobExecutorServiceHandlerType, jobErrorHandlerType, jobListenerTypes, extraConfigurations, description, props, disabled, overwrite);
+                    jobShardingStrategyType, jobExecutorServiceHandlerType, jobErrorHandlerType, jobListenerTypes,
+                    extraConfigurations, description, props, disabled, overwrite, label, staticSharding);
         }
     }
 }
diff --git a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJO.java b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJO.java
index 61e7341..1e7f1c8 100644
--- a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJO.java
+++ b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJO.java
@@ -75,6 +75,10 @@ public final class JobConfigurationPOJO {
     
     private boolean overwrite;
     
+    private String label;
+    
+    private boolean staticSharding;
+    
     /**
      * Convert to job configuration.
      * 
@@ -123,6 +127,8 @@ public final class JobConfigurationPOJO {
         result.setProps(jobConfiguration.getProps());
         result.setDisabled(jobConfiguration.isDisabled());
         result.setOverwrite(jobConfiguration.isOverwrite());
+        result.setLabel(jobConfiguration.getLabel());
+        result.setStaticSharding(jobConfiguration.isStaticSharding());
         return result;
     }
 }
diff --git a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java
index b7b50ab..8ae62a6 100644
--- a/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java
+++ b/elasticjob-infra/elasticjob-infra-common/src/test/java/org/apache/shardingsphere/elasticjob/infra/pojo/JobConfigurationPOJOTest.java
@@ -49,7 +49,8 @@ public final class JobConfigurationPOJOTest {
             + "  key: value\n"
             + "reconcileIntervalMinutes: 0\n"
             + "shardingItemParameters: 0=A,1=B,2=C\n"
-            + "shardingTotalCount: 3\n";
+            + "shardingTotalCount: 3\n"
+            + "staticSharding: false\n";
     
     private static final String YAML_WITH_NULL = "cron: 0/1 * * * * ?\n"
             + "disabled: false\n"
@@ -60,7 +61,8 @@ public final class JobConfigurationPOJOTest {
             + "monitorExecution: false\n"
             + "overwrite: false\n"
             + "reconcileIntervalMinutes: 0\n"
-            + "shardingTotalCount: 3\n";
+            + "shardingTotalCount: 3\n"
+            + "staticSharding: false\n";
     
     @Test
     public void assertToJobConfiguration() {
diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileService.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileService.java
index 4d79186..20afc62 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileService.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileService.java
@@ -21,6 +21,7 @@ import com.google.common.util.concurrent.AbstractScheduledService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
 import org.apache.shardingsphere.elasticjob.lite.internal.sharding.ShardingService;
+import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodePath;
 import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
 
 import java.util.concurrent.TimeUnit;
@@ -37,10 +38,16 @@ public final class ReconcileService extends AbstractScheduledService {
     
     private final ShardingService shardingService;
     
+    private final JobNodePath jobNodePath;
+    
+    private final CoordinatorRegistryCenter regCenter;
+    
     public ReconcileService(final CoordinatorRegistryCenter regCenter, final String jobName) {
+        this.regCenter = regCenter;
         lastReconcileTime = System.currentTimeMillis();
         configService = new ConfigurationService(regCenter, jobName);
         shardingService = new ShardingService(regCenter, jobName);
+        jobNodePath = new JobNodePath(jobName);
     }
     
     @Override
@@ -48,13 +55,21 @@ public final class ReconcileService extends AbstractScheduledService {
         int reconcileIntervalMinutes = configService.load(true).getReconcileIntervalMinutes();
         if (reconcileIntervalMinutes > 0 && (System.currentTimeMillis() - lastReconcileTime >= reconcileIntervalMinutes * 60 * 1000)) {
             lastReconcileTime = System.currentTimeMillis();
-            if (!shardingService.isNeedSharding() && shardingService.hasShardingInfoInOfflineServers()) {
+            if (!shardingService.isNeedSharding() && shardingService.hasShardingInfoInOfflineServers() && !(isStaticSharding() && hasShardingInfo())) {
                 log.warn("Elastic Job: job status node has inconsistent value,start reconciling...");
                 shardingService.setReshardingFlag();
             }
         }
     }
     
+    private boolean isStaticSharding() {
+        return configService.load(true).isStaticSharding();
+    }
+    
+    private boolean hasShardingInfo() {
+        return !regCenter.getChildrenKeys(jobNodePath.getShardingNodePath()).isEmpty();
+    }
+    
     @Override
     protected Scheduler scheduler() {
         return Scheduler.newFixedDelaySchedule(0, 1, TimeUnit.MINUTES);
diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManager.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManager.java
index 9418c5a..74b3a44 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManager.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManager.java
@@ -17,14 +17,16 @@
 
 package org.apache.shardingsphere.elasticjob.lite.internal.sharding;
 
+import org.apache.shardingsphere.elasticjob.infra.pojo.JobConfigurationPOJO;
 import org.apache.shardingsphere.elasticjob.infra.yaml.YamlEngine;
 import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationNode;
-import org.apache.shardingsphere.elasticjob.infra.pojo.JobConfigurationPOJO;
+import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
 import org.apache.shardingsphere.elasticjob.lite.internal.instance.InstanceNode;
 import org.apache.shardingsphere.elasticjob.lite.internal.listener.AbstractJobListener;
 import org.apache.shardingsphere.elasticjob.lite.internal.listener.AbstractListenerManager;
 import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
 import org.apache.shardingsphere.elasticjob.lite.internal.server.ServerNode;
+import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodePath;
 import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
 
 /**
@@ -42,6 +44,10 @@ public final class ShardingListenerManager extends AbstractListenerManager {
     
     private final ShardingService shardingService;
     
+    private final JobNodePath jobNodePath;
+    
+    private final ConfigurationService configService;
+    
     public ShardingListenerManager(final CoordinatorRegistryCenter regCenter, final String jobName) {
         super(regCenter, jobName);
         this.jobName = jobName;
@@ -49,6 +55,8 @@ public final class ShardingListenerManager extends AbstractListenerManager {
         instanceNode = new InstanceNode(jobName);
         serverNode = new ServerNode(jobName);
         shardingService = new ShardingService(regCenter, jobName);
+        jobNodePath = new JobNodePath(jobName);
+        configService = new ConfigurationService(regCenter, jobName);
     }
     
     @Override
@@ -75,11 +83,19 @@ public final class ShardingListenerManager extends AbstractListenerManager {
         
         @Override
         protected void dataChanged(final String path, final Type eventType, final String data) {
-            if (!JobRegistry.getInstance().isShutdown(jobName) && (isInstanceChange(eventType, path) || isServerChange(path))) {
+            if (!JobRegistry.getInstance().isShutdown(jobName) && (isInstanceChange(eventType, path) || isServerChange(path)) && !(isStaticSharding() && hasShardingInfo())) {
                 shardingService.setReshardingFlag();
             }
         }
         
+        private boolean isStaticSharding() {
+            return configService.load(true).isStaticSharding();
+        }
+        
+        private boolean hasShardingInfo() {
+            return !JobRegistry.getInstance().getRegCenter(jobName).getChildrenKeys(jobNodePath.getShardingNodePath()).isEmpty();
+        }
+        
         private boolean isInstanceChange(final Type eventType, final String path) {
             return instanceNode.isInstancePath(path) && Type.NODE_CHANGED != eventType;
         }
diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileServiceTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileServiceTest.java
index 850cf18..1d0ed12 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileServiceTest.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/reconcile/ReconcileServiceTest.java
@@ -17,18 +17,21 @@
 
 package org.apache.shardingsphere.elasticjob.lite.internal.reconcile;
 
+import com.google.common.collect.Lists;
 import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
 import org.apache.shardingsphere.elasticjob.infra.handler.sharding.JobInstance;
 import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
 import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
 import org.apache.shardingsphere.elasticjob.lite.internal.sharding.ShardingService;
 import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
@@ -41,12 +44,15 @@ public final class ReconcileServiceTest {
     @Mock
     private ShardingService shardingService;
     
+    @Mock
+    private CoordinatorRegistryCenter regCenter;
+    
     private ReconcileService reconcileService;
     
     @Before
     public void setup() {
         JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0"));
-        reconcileService = new ReconcileService(null, "test_job");
+        reconcileService = new ReconcileService(regCenter, "test_job");
         ReflectionUtils.setFieldValue(reconcileService, "lastReconcileTime", 1L);
         ReflectionUtils.setFieldValue(reconcileService, "configService", configService);
         ReflectionUtils.setFieldValue(reconcileService, "shardingService", shardingService);
@@ -62,4 +68,16 @@ public final class ReconcileServiceTest {
         verify(shardingService).hasShardingInfoInOfflineServers();
         verify(shardingService).setReshardingFlag();
     }
+    
+    @Test
+    public void assertReconcileWithStaticSharding() {
+        when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").reconcileIntervalMinutes(1).staticSharding(true).build());
+        when(shardingService.isNeedSharding()).thenReturn(false);
+        when(shardingService.hasShardingInfoInOfflineServers()).thenReturn(true);
+        when(regCenter.getChildrenKeys("/test_job/sharding")).thenReturn(Lists.newArrayList("0"));
+        reconcileService.runOneIteration();
+        verify(shardingService).isNeedSharding();
+        verify(shardingService).hasShardingInfoInOfflineServers();
+        verify(shardingService, times(0)).setReshardingFlag();
+    }
 }
diff --git a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java
index df34059..9043e7e 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/sharding/ShardingListenerManagerTest.java
@@ -17,15 +17,18 @@
 
 package org.apache.shardingsphere.elasticjob.lite.internal.sharding;
 
+import com.google.common.collect.Lists;
 import org.apache.curator.framework.recipes.cache.CuratorCacheListener.Type;
-import org.apache.shardingsphere.elasticjob.lite.fixture.LiteYamlConstants;
+import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
 import org.apache.shardingsphere.elasticjob.infra.handler.sharding.JobInstance;
+import org.apache.shardingsphere.elasticjob.lite.fixture.LiteYamlConstants;
+import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
 import org.apache.shardingsphere.elasticjob.lite.internal.listener.AbstractJobListener;
 import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
 import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduleController;
 import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodeStorage;
-import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
 import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
+import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -35,6 +38,7 @@ import org.mockito.junit.MockitoJUnitRunner;
 
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 @RunWith(MockitoJUnitRunner.class)
 public final class ShardingListenerManagerTest {
@@ -51,6 +55,9 @@ public final class ShardingListenerManagerTest {
     @Mock
     private ShardingService shardingService;
     
+    @Mock
+    private ConfigurationService configService;
+    
     private ShardingListenerManager shardingListenerManager;
     
     @Before
@@ -59,6 +66,7 @@ public final class ShardingListenerManagerTest {
         shardingListenerManager = new ShardingListenerManager(null, "test_job");
         ReflectionUtils.setSuperclassFieldValue(shardingListenerManager, "jobNodeStorage", jobNodeStorage);
         ReflectionUtils.setFieldValue(shardingListenerManager, "shardingService", shardingService);
+        ReflectionUtils.setFieldValue(shardingListenerManager, "configService", configService);
     }
     
     @Test
@@ -117,6 +125,7 @@ public final class ShardingListenerManagerTest {
     public void assertListenServersChangedJobListenerWhenIsInstanceChange() {
         JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter);
         JobRegistry.getInstance().registerJob("test_job", jobScheduleController);
+        when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 1).build());
         shardingListenerManager.new ListenServersChangedJobListener().dataChanged("/test_job/instances/xxx", Type.NODE_CREATED, "");
         verify(shardingService).setReshardingFlag();
         JobRegistry.getInstance().shutdown("test_job");
@@ -126,8 +135,20 @@ public final class ShardingListenerManagerTest {
     public void assertListenServersChangedJobListenerWhenIsServerChange() {
         JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter);
         JobRegistry.getInstance().registerJob("test_job", jobScheduleController);
+        when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 1).build());
         shardingListenerManager.new ListenServersChangedJobListener().dataChanged("/test_job/servers/127.0.0.1", Type.NODE_CHANGED, "");
         verify(shardingService).setReshardingFlag();
         JobRegistry.getInstance().shutdown("test_job");
     }
+    
+    @Test
+    public void assertListenServersChangedJobListenerWhenIsStaticSharding() {
+        JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter);
+        JobRegistry.getInstance().registerJob("test_job", jobScheduleController);
+        when(configService.load(true)).thenReturn(JobConfiguration.newBuilder("test_job", 1).staticSharding(true).build());
+        when(regCenter.getChildrenKeys("/test_job/sharding")).thenReturn(Lists.newArrayList("0"));
+        shardingListenerManager.new ListenServersChangedJobListener().dataChanged("/test_job/servers/127.0.0.1", Type.NODE_CHANGED, "");
+        verify(shardingService, times(0)).setReshardingFlag();
+        JobRegistry.getInstance().shutdown("test_job");
+    }
 }
diff --git a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleYamlConstants.java b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleYamlConstants.java
index b9e2db8..aaa5a06 100644
--- a/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleYamlConstants.java
+++ b/elasticjob-lite/elasticjob-lite-lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lite/lifecycle/fixture/LifecycleYamlConstants.java
@@ -49,7 +49,8 @@ public final class LifecycleYamlConstants {
             + "props:\n"
             + "  streaming.process: 'true'\n"
             + "reconcileIntervalMinutes: 10\n"
-            + "shardingTotalCount: 3\n";
+            + "shardingTotalCount: 3\n"
+            + "staticSharding: false\n";
     
     private static final String SCRIPT_JOB_YAML = "jobName: test_job\n"
             + "cron: 0/1 * * * * ?\n"
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/parser/JobBeanDefinitionParser.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/parser/JobBeanDefinitionParser.java
index c97dce6..e532d69 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/parser/JobBeanDefinitionParser.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/parser/JobBeanDefinitionParser.java
@@ -88,6 +88,8 @@ public final class JobBeanDefinitionParser extends AbstractBeanDefinitionParser
         result.addConstructorArgValue(parsePropsElement(element, parserContext));
         result.addConstructorArgValue(element.getAttribute(JobBeanDefinitionTag.DISABLED_ATTRIBUTE));
         result.addConstructorArgValue(element.getAttribute(JobBeanDefinitionTag.OVERWRITE_ATTRIBUTE));
+        result.addConstructorArgValue(element.getAttribute(JobBeanDefinitionTag.LABEL_ATTRIBUTE));
+        result.addConstructorArgValue(element.getAttribute(JobBeanDefinitionTag.STATIC_SHARDING_ATTRIBUTE));
         return result.getBeanDefinition();
     }
     
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/tag/JobBeanDefinitionTag.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/tag/JobBeanDefinitionTag.java
index 6001029..617dde5 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/tag/JobBeanDefinitionTag.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/namespace/job/tag/JobBeanDefinitionTag.java
@@ -67,4 +67,8 @@ public final class JobBeanDefinitionTag {
     public static final String DISABLED_ATTRIBUTE = "disabled";
     
     public static final String OVERWRITE_ATTRIBUTE = "overwrite";
+    
+    public static final String LABEL_ATTRIBUTE = "label";
+    
+    public static final String STATIC_SHARDING_ATTRIBUTE = "static-sharding";
 }
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/resources/META-INF/namespace/elasticjob.xsd b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/resources/META-INF/namespace/elasticjob.xsd
index 2fb7286..372da0f 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/resources/META-INF/namespace/elasticjob.xsd
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-namespace/src/main/resources/META-INF/namespace/elasticjob.xsd
@@ -50,6 +50,8 @@
                     <xsd:attribute name="description" type="xsd:string" />
                     <xsd:attribute name="disabled" type="xsd:string" default="false" />
                     <xsd:attribute name="overwrite" type="xsd:string" default="false" />
+                    <xsd:attribute name="label" type="xsd:string" />
+                    <xsd:attribute name="static-sharding" type="xsd:string" default="false" />
                 </xsd:extension>
             </xsd:complexContent>
         </xsd:complexType>