当前位置: 首页>>代码示例>>Java>>正文


Java TestSecurityMockRM类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM的典型用法代码示例。如果您正苦于以下问题:Java TestSecurityMockRM类的具体用法?Java TestSecurityMockRM怎么用?Java TestSecurityMockRM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestSecurityMockRM类属于org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart包,在下文中一共展示了TestSecurityMockRM类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAppSubmissionWithoutDelegationToken

import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM; //导入依赖的package包/类
@Test
public void testAppSubmissionWithoutDelegationToken() throws Exception {
  conf.setBoolean(YarnConfiguration.RM_PROXY_USER_PRIVILEGES_ENABLED, true);
  // create token2
  Text userText2 = new Text("user2");
  DelegationTokenIdentifier dtId2 =
      new DelegationTokenIdentifier(new Text("user2"), new Text("renewer2"),
        userText2);
  final Token<DelegationTokenIdentifier> token2 =
      new Token<DelegationTokenIdentifier>(dtId2.getBytes(),
        "password2".getBytes(), dtId2.getKind(), new Text("service2"));
  final MockRM rm = new TestSecurityMockRM(conf, null) {
    @Override
    protected DelegationTokenRenewer createDelegationTokenRenewer() {
      return new DelegationTokenRenewer() {
        @Override
        protected Token<?>[] obtainSystemTokensForUser(String user,
            final Credentials credentials) throws IOException {
          credentials.addToken(token2.getService(), token2);
          return new Token<?>[] { token2 };
        }
      };
    }
  };
  rm.start();

  // submit an app without delegationToken
  RMApp app = rm.submitApp(200);

  // wait for the new retrieved hdfs token.
  GenericTestUtils.waitFor(new Supplier<Boolean>() {
    public Boolean get() {
      return rm.getRMContext().getDelegationTokenRenewer()
        .getDelegationTokens().contains(token2);
    }
  }, 1000, 20000);

  // check nm can retrieve the token
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();
  NodeHeartbeatResponse response = nm1.nodeHeartbeat(true);
  ByteBuffer tokenBuffer =
      response.getSystemCredentialsForApps().get(app.getApplicationId());
  Assert.assertNotNull(tokenBuffer);
  Credentials appCredentials = new Credentials();
  DataInputByteBuffer buf = new DataInputByteBuffer();
  tokenBuffer.rewind();
  buf.reset(tokenBuffer);
  appCredentials.readTokenStorageStream(buf);
  Assert.assertTrue(appCredentials.getAllTokens().contains(token2));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:53,代码来源:TestDelegationTokenRenewer.java

示例2: testAppSubmissionWithPreviousToken

import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM; //导入依赖的package包/类
@Test (timeout = 30000)
public void testAppSubmissionWithPreviousToken() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(userText1, token1);

  // submit app1 with a token, set cancelTokenWhenComplete to false;
  RMApp app1 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, false);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  // submit app2 with the same token, set cancelTokenWhenComplete to true;
  RMApp app2 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  Assert.assertTrue(rm.getRMContext().getDelegationTokenRenewer()
    .getAllTokens().containsKey(token1));

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertFalse(Renewer.cancelled);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:42,代码来源:TestDelegationTokenRenewer.java

示例3: testCancelWithMultipleAppSubmissions

import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM; //导入依赖的package包/类
@Test (timeout = 30000)
public void testCancelWithMultipleAppSubmissions() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  //MyFS fs = (MyFS)FileSystem.get(conf);
  //MyToken token1 = fs.getDelegationToken("user123");

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(token1.getService(), token1);

  DelegationTokenRenewer renewer =
      rm.getRMContext().getDelegationTokenRenewer();
  Assert.assertTrue(renewer.getAllTokens().isEmpty());
  Assert.assertFalse(Renewer.cancelled);

  RMApp app1 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  DelegationTokenToRenew dttr = renewer.getAllTokens().get(token1);
  Assert.assertNotNull(dttr);
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  RMApp app2 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertFalse(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  RMApp app3 =
      rm.submitApp(200, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true);
  MockAM am3 = MockRM.launchAndRegisterAM(app3, rm, nm1);
  rm.waitForState(app3.getApplicationId(), RMAppState.RUNNING);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertFalse(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app3, rm, nm1, am3);
  Assert.assertFalse(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.isEmpty());
  Assert.assertTrue(dttr.isTimerCancelled());
  Assert.assertTrue(Renewer.cancelled);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:80,代码来源:TestDelegationTokenRenewer.java

示例4: testAppFailedToRenewTokenOnRecovery

import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM; //导入依赖的package包/类
@Test (timeout = 30000)
public void testAppFailedToRenewTokenOnRecovery() throws Exception {
  conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
    "kerberos");
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 1);
  UserGroupInformation.setConfiguration(conf);
  MemoryRMStateStore memStore = new MemoryRMStateStore();
  memStore.init(conf);
  MockRM rm1 = new TestSecurityMockRM(conf, memStore);
  rm1.start();
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 8192, rm1.getResourceTrackerService());
  nm1.registerNode();
  RMApp app1 = rm1.submitApp(200);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1);

  MockRM rm2 = new TestSecurityMockRM(conf, memStore) {
    protected DelegationTokenRenewer createDelegationTokenRenewer() {
      return new DelegationTokenRenewer() {
        @Override
        public void addApplicationSync(ApplicationId applicationId,
            Credentials ts, boolean shouldCancelAtEnd, String user)
            throws IOException {
          throw new IOException("Token renew failed !!");
        }
      };
    }
  };
  nm1.setResourceTrackerService(rm2.getResourceTrackerService());
  rm2.start();
  NMContainerStatus containerStatus =
      TestRMRestart.createNMContainerStatus(am1.getApplicationAttemptId(), 1,
        ContainerState.RUNNING);
  nm1.registerNode(Arrays.asList(containerStatus), null);

  // am re-register
  rm2.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED);
  am1.setAMRMProtocol(rm2.getApplicationMasterService(), rm2.getRMContext());
  am1.registerAppAttempt(true);
  rm2.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  // Because the token expired, am could crash.
  nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  rm2.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED);
  rm2.waitForState(app1.getApplicationId(), RMAppState.FAILED);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:TestWorkPreservingRMRestart.java

示例5: testAppSubmissionWithPreviousToken

import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM; //导入依赖的package包/类
@Test (timeout = 30000)
public void testAppSubmissionWithPreviousToken() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(userText1, token1);

  // submit app1 with a token, set cancelTokenWhenComplete to false;
  Resource resource = Records.newRecord(Resource.class);
  resource.setMemory(200);
  RMApp app1 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, false, null);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  // submit app2 with the same token, set cancelTokenWhenComplete to true;
  RMApp app2 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, true, null);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  Assert.assertTrue(rm.getRMContext().getDelegationTokenRenewer()
    .getAllTokens().containsKey(token1));

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertFalse(Renewer.cancelled);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:42,代码来源:TestDelegationTokenRenewer.java

示例6: testCancelWithMultipleAppSubmissions

import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM; //导入依赖的package包/类
@Test (timeout = 30000)
public void testCancelWithMultipleAppSubmissions() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  //MyFS fs = (MyFS)FileSystem.get(conf);
  //MyToken token1 = fs.getDelegationToken("user123");

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(token1.getService(), token1);

  DelegationTokenRenewer renewer =
      rm.getRMContext().getDelegationTokenRenewer();
  Assert.assertTrue(renewer.getAllTokens().isEmpty());
  Assert.assertFalse(Renewer.cancelled);

  Resource resource = Records.newRecord(Resource.class);
  resource.setMemory(200);
  RMApp app1 =
      rm.submitApp(resource, "name", "user", null, false, null, 2, credentials,
        null, true, false, false, null, 0, null, true, null);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  DelegationTokenToRenew dttr = renewer.getAllTokens().get(token1);
  Assert.assertNotNull(dttr);
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  RMApp app2 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, true, null);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertFalse(dttr.referringAppIds.contains(app2.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  RMApp app3 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, true, null);
  MockAM am3 = MockRM.launchAndRegisterAM(app3, rm, nm1);
  rm.waitForState(app3.getApplicationId(), RMAppState.RUNNING);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  Assert.assertTrue(renewer.getAllTokens().containsKey(token1));
  Assert.assertFalse(dttr.referringAppIds.contains(app1.getApplicationId()));
  Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId()));
  Assert.assertFalse(dttr.isTimerCancelled());
  Assert.assertFalse(Renewer.cancelled);

  MockRM.finishAMAndVerifyAppState(app3, rm, nm1, am3);
  Assert.assertFalse(renewer.getAllTokens().containsKey(token1));
  Assert.assertTrue(dttr.referringAppIds.isEmpty());
  Assert.assertTrue(dttr.isTimerCancelled());
  Assert.assertTrue(Renewer.cancelled);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:80,代码来源:TestDelegationTokenRenewer.java

示例7: testAppSubmissionWithPreviousToken

import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM; //导入依赖的package包/类
@Test (timeout = 30000)
public void testAppSubmissionWithPreviousToken() throws Exception{
  MockRM rm = new TestSecurityMockRM(conf, null);
  rm.start();
  final MockNM nm1 =
      new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService());
  nm1.registerNode();

  // create Token1:
  Text userText1 = new Text("user");
  DelegationTokenIdentifier dtId1 =
      new DelegationTokenIdentifier(userText1, new Text("renewer1"),
        userText1);
  final Token<DelegationTokenIdentifier> token1 =
      new Token<DelegationTokenIdentifier>(dtId1.getBytes(),
        "password1".getBytes(), dtId1.getKind(), new Text("service1"));

  Credentials credentials = new Credentials();
  credentials.addToken(userText1, token1);

  // submit app1 with a token, set cancelTokenWhenComplete to false;
  Resource resource = Records.newRecord(Resource.class);
  resource.setMemorySize(200);
  RMApp app1 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, false, null);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1);
  rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  // submit app2 with the same token, set cancelTokenWhenComplete to true;
  RMApp app2 = rm.submitApp(resource, "name", "user", null, false, null, 2,
      credentials, null, true, false, false, null, 0, null, true, null);
  MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1);
  rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING);
  MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2);
  Assert.assertTrue(rm.getRMContext().getDelegationTokenRenewer()
    .getAllTokens().containsKey(token1));

  MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1);
  // app2 completes, app1 is still running, check the token is not cancelled
  Assert.assertFalse(Renewer.cancelled);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:42,代码来源:TestDelegationTokenRenewer.java

示例8: testAppFailedToRenewTokenOnRecovery

import org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM; //导入依赖的package包/类
@Test (timeout = 30000)
public void testAppFailedToRenewTokenOnRecovery() throws Exception {
  conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
    "kerberos");
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 1);
  UserGroupInformation.setConfiguration(conf);
  MockRM rm1 = new TestSecurityMockRM(conf, null);
  rm1.start();
  Assume.assumeFalse(rm1.getResourceScheduler() instanceof FairScheduler);
  MockNM nm1 =
      new MockNM("127.0.0.1:1234", 8192, rm1.getResourceTrackerService());
  nm1.registerNode();
  RMApp app1 = rm1.submitApp(200);
  MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1);

  MockRM rm2 = new TestSecurityMockRM(conf, null) {
    protected DelegationTokenRenewer createDelegationTokenRenewer() {
      return new DelegationTokenRenewer() {
        @Override
        public void addApplicationSync(ApplicationId applicationId,
            Credentials ts, boolean shouldCancelAtEnd, String user)
            throws IOException {
          throw new IOException("Token renew failed !!");
        }
      };
    }
  };
  nm1.setResourceTrackerService(rm2.getResourceTrackerService());
  rm2.start();
  NMContainerStatus containerStatus =
      TestRMRestart.createNMContainerStatus(am1.getApplicationAttemptId(), 1,
        ContainerState.RUNNING);
  nm1.registerNode(Arrays.asList(containerStatus), null);

  // am re-register
  rm2.waitForState(app1.getApplicationId(), RMAppState.ACCEPTED);
  am1.setAMRMProtocol(rm2.getApplicationMasterService(), rm2.getRMContext());
  am1.registerAppAttempt(true);
  rm2.waitForState(app1.getApplicationId(), RMAppState.RUNNING);

  // Because the token expired, am could crash.
  nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  rm2.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED);
  rm2.waitForState(app1.getApplicationId(), RMAppState.FAILED);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:46,代码来源:TestWorkPreservingRMRestart.java


注:本文中的org.apache.hadoop.yarn.server.resourcemanager.TestRMRestart.TestSecurityMockRM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。