奥门新浦京官方网站12.配置Config

本文这里通过示例给大家简单对比分析了PHP
数组current和next的用法,虽然示例很简单,但是对于我们理解current和next非常有帮助,这里推荐给大家。

目录:

配置

Parse.Config是一种通过在Parse上存储单个Config对象来远程配置应用程序的好方法。它使您可添加功能开关或简单的“每日消息”等功能。要使用Parse.Config,您需要在Parse
Config Dashboard上向应用程序添加一些键/值对(参数)。

之后,您可以在客户端获取Parse.Config,例如:

Parse.Config.get().then(function(config) {
  var winningNumber = config.get("winningNumber");
  var message = "Yay! The number is " + winningNumber + "!";
  console.log(message);
}, function(error) {
  // Something went wrong (e.g. request timed out)
});

1.current

  • 连接hadoop配置语法
  • 配置hadoop连接
  • Pushdown配置
  • Create external tables for Azure blob
    storage

1.检索配置

即使在网络连接不畅的情况下,ParseConfig仍然保持尽可能的强大可靠。默认情况下会使用缓存来确保最新成功获取的配置始终可用。在下面的示例中,我们使用get从服务器检索最新版本的配置,如果提取失败,我们可以通过current直接回滚到我们之前成功获取的版本。

Parse.Config.get().then(function(config) {
  console.log("Yay! Config was fetched from the server.");

  var welcomeMessage = config.get("welcomeMessage");
  console.log("Welcome Message = " + welcomeMessage);
}, function(error) {
  console.log("Failed to fetch. Using Cached Config.");

  var config = Parse.Config.current();
  var welcomeMessage = config.get("welcomeMessage");
  if (welcomeMessage === undefined) {
    welcomeMessage = "Welcome!";
  }
  console.log("Welcome Message = " + welcomeMessage);
});
<?php
 $transport = array('foot', 'bike', 'car', 'plane');
 $mode = current($transport); //$mode = 'foot';
 $mode = next($transport);   // $mode ='bike';
 $mode = current($transport); //$mode = 'bike';
 $mode = prev($transport);   // $mode ='foot';
 $mode = end($transport);    // $mode ='plane';
 $mode = current($transport); //$mode = 'plane';
 ?>

连接hadoop配置语法:  

2.当前配置

你得到的每一个Parse.Config实例始终保持不变。当您以后从网络中检索到新的Parse.Config实例时,它将不会修改任何现有的实例,而是创建一个新的实例,并通过Parse.Config.current()使其可用。因此,您可以安全地绕过任何current()对象,并放心地假定它不会自动更改。

每当您想要使用配置时都从服务器检索可能很麻烦。您可以直接使用缓存的current()对象和仅定时获取配置来避免这种情况。

// Fetches the config at most once every 12 hours per app runtime
var refreshConfig = function() {
  var lastFetchedDate;
  var configRefreshInterval = 12 * 60 * 60 * 1000;
  return function() {
    var currentDate = new Date();
    if (lastFetchedDate === undefined ||
        currentDate.getTime() - lastFetchedDate.getTime() > configRefreshInterval) {
      Parse.Config.get();
      lastFetchedDate = currentDate;
    }
  };
}();

2.next


3.参数

通过Parse.Object,ParseConfig支持大多数数据类型:

  • string
  • number
  • Date
  • Parse.File
  • Parse.GeoPoint
  • JS Array
  • JS Object

我们目前在配置中最多允许100个参数,并且所有参数的总大小不超过128KB。

<?php
 $transport = array('foot', 'bike', 'car', 'plane');
 $mode = current($transport); //$mode = 'foot';
 $mode = next($transport);   // $mode ='bike';
 $mode = next($transport);   // $mode ='car';
 $mode = prev($transport);   // $mode ='bike';
 $mode = end($transport);    // $mode ='plane';
 ?>

global configuration settings for
PolyBase Hadoop and Azure blob storage connectivity, Syntax:

示例很简单,但是却很实用,希望小伙伴们能够喜欢。

  • sp_configure:  List all of the
    configuration options
  • 配置与hadoop连接语法:
  • sp_configure [ @configname = ] ‘hadoop connectivity’,

                 [ @configvalue = ] { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 }  
    [;]  
    
    RECONFIGURE  
    [;]
    

     

  1. Option 0: Disable Hadoop
    connectivity
  2. Option 1: Hortonworks HDP 1.3 on
    Windows Server
  3. Option 1: Azure blob storage
    (WASB[S])
  4. Option 2: Hortonworks HDP 1.3 on
    Linux
  5. Option 3: Cloudera CDH 4.3 on
    Linux
  6. Option 4: Hortonworks HDP 2.0 on
    Windows Server
  7. Option 4: Azure blob storage
    (WASB[S])
  8. Option 5: Hortonworks HDP 2.0 on
    Linux
  9. Option 6: Cloudera 5.1, 5.2, 5.3,
    5.4, and 5.5 on Linux
  10. Option 7: Hortonworks 2.1, 2.2, and
    2.3 on Linux
  11. Option 7: Hortonworks 2.1, 2.2, and
    2.3 on Windows Server
  12. Option 7: Azure blob storage
    (WASB[S])
          
  • 示例代码:
  1. 显示所有可用的配置列表: EXEC sp_configure;
  2. 显示某个配置项的配置信息:  EXEC sp_configure @configname=’hadoop
    connectivity’;
  3. 设置配置项示例语法如下:       
  4. sp_configure @configname = ‘hadoop connectivity’, @configvalue = 7;

    GO  
    
    RECONFIGURE  
    GO   
    

     

 配置hadoop连接


  • 在本节示例中,连接HDInsight3.2集,对应关系如下:
  • 奥门新浦京官方网站 1
  • 配置polybase连接配置项信息信息如下:
  • sp_configure @configname = ‘hadoop connectivity’, @configvalue = 7;

    GO  
    
    RECONFIGURE  
    GO
    

     

  • 命令行:  services.msc,
    重启下面的服务

    1. SQL Server
      PolyBase Data Movement Service
    2. SQL Server
      PolyBase Engine

 Pushdown配置:


  • To improve query performance, enable
    pushdown computation to a Hadoop cluster
  1. Find the file yarn-site.xml in the installation path of SQL Server.
    Typically, the path is: C:Program FilesMicrosoft SQL
    ServerMSSQL13.MSSQLSERVERMSSQLBinnPolybaseHadoopconf

  2. On the Hadoop machine, find the
    analogous(类似) file in the Hadoop configuration directory. In the
    file, find and copy the value of the configuration key yarn.application.classpath

  3. On the SQL Server
    machine, in the yarn-site.xml file, find the yarn.application.classpath property. Paste
    the value from the Hadoop machine into the value
    element.
  4. $HADOOP_CONF_DIR,/usr/hdp/current/hadoop-client/,/usr/hdp/current/hadoop-client/lib/,/usr/hdp/current/hadoop-hdfs-client/,/usr/hdp/current/hadoop-hdfs-client/lib/,/usr/hdp/current/hadoop-yarn-client/,/usr/hdp/current/hadoop-yarn-client/lib/ 

 Create external tables for Azure blob
storage


  • The Elastic(弹性) Database query
    feature relies on(依靠) the these four DDL statements. Typically,
    these DDL statements are used once or rarely when the schema of your
    application changes
    1. [CREATE MASTER KEY]  
       ()
    2. [CREATE CREDENTIAL]   
      ()
    3. [CREATE DATABASE SCOPED
      CREDENTIAL]  
      ()
    4. [CREATE/DROP EXTERNAL DATA
      SOURCE]   
      ()
    5. [CREATE/DROP EXTERNAL
      TABLE]               
      ()
  • You can use the following syntax to
    drop the master key and credentials
    1. DROP CREDENTIAL
      <credential_name> ON DATABASE;
    2. DROP DATABASE SCOPED CREDENTIAL
      <credential_name>;
    3. DROP MASTER KEY; 
  • 模拟简单文本数据,如下:
  •      
    奥门新浦京官方网站 2
  • 将文本文件上传到 Azure blob storage,
    如下图:
  • 奥门新浦京官方网站 3
  • 远程连接ploybase1, 打开ssms(注:此版本需单独安装),执行脚本如下:
  • CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘Password01!’;

    CREATE DATABASE SCOPED CREDENTIAL JNAzureCredit   
    WITH IDENTITY = 'zhushy', Secret =  XXXX';  /*存储访问Key*/ 
    
    CREATE EXTERNAL DATA SOURCE JNAzureStorage with (  
            TYPE = HADOOP,   
            LOCATION ='wasb://<blob_container_name>@<azure_storage_account_name>.blob.core.chinacloudapi.cn',  
            CREDENTIAL = JNAzureCredit  
    );


    CREATE EXTERNAL FILE FORMAT TextFileFormat WITH (  
            FORMAT_TYPE = DELIMITEDTEXT,   
            FORMAT_OPTIONS (FIELD_TERMINATOR =' ', USE_TYPE_DEFAULT = TRUE))

    CREATE EXTERNAL TABLE [dbo].[hospital] (  
            [ID] varchar(128) NULL,
            [name] varchar(128) null
    )  
    WITH (LOCATION='/zhu/data1.txt',   
            DATA_SOURCE = JNAzureStorage,  
            FILE_FORMAT = TextFileFormat  
    );  

 
  • 验证数据,输入如下SQL: select *
    from [dbo].[hospital] ,如下图,则OK
  • 奥门新浦京官方网站 4

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注