├── sqoop_full.sh ├── gen_create_tbl.py ├── daily_append.sh ├── initialize_table.sh ├── daily_merge.sh └── LICENSE /sqoop_full.sh: -------------------------------------------------------------------------------- 1 | source common_env.sh 2 | 3 | [ $# -eq 0 ] && { echo "Usage: $0 table_name num_mappers"; exit 1; } 4 | 5 | echo Step 1: Clean existing data 6 | hdfs dfs -rm -r /${top_dir}/${table_name} 7 | hdfs dfs -rm -r /${metadata_dir}/${schema_name} 8 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "drop table ${db_name}.${table_name}" 9 | 10 | echo Step2: Sqoop the data from Oracle 11 | sqoop import -D oraoop.disabled=true --connect ${connect_string} --table ${table_name} --verbose --username ${user_name} --password-file ${password_file} --as-avrodatafile --warehouse-dir /${top_dir} 12 | 13 | echo Step 3: Extract AVRO schema and load to HDFS 14 | hadoop jar /opt/cloudera/parcels/CDH/lib/avro/avro-tools.jar getschema hdfs://nameservice1/${top_dir}/${table_name}/part-m-00000.avro > /tmp/${schema_name} 15 | ./gen_create_tbl.py ${table_name} hdfs://nameservice1/${top_dir}/${table_name} hdfs://nameservice1/${metadata_dir}/${schema_name} > /tmp/${table_name}.ddl 16 | 17 | hdfs dfs -put /tmp/${schema_name} /${metadata_dir} 18 | 19 | echo Step 4: Create Hive table 20 | 21 | #beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "CREATE EXTERNAL TABLE ${db_name}.${table_name} ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' location 'hdfs://nameservice1/${top_dir}/${table_name}' TBLPROPERTIES ( 'avro.schema.url'='hdfs://nameservice1/${metadata_dir}/${schema_name}') " 22 | 23 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -f /tmp/${table_name}.ddl 24 | -------------------------------------------------------------------------------- /gen_create_tbl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import json 3 | import subprocess 4 | import sys 5 | 6 | def convertType(type): 7 | if type=="long": 8 | return "bigint" 9 | else: 10 | return type 11 | 12 | def gen_columns(schema): 13 | ret = "(" + ",".join(['%s %s' % (field['name'],convertType(field['type'][0])) for (field) in schema['fields']]) + ")" 14 | return ret 15 | 16 | def read_schema_file(hdfspath): 17 | p = subprocess.Popen(['hdfs','dfs','-cat',hdfspath],stdout=subprocess.PIPE) 18 | return p.communicate()[0] 19 | 20 | def usage(argNum): 21 | print ("Wrong number of arguments: " + `argNum`) 22 | print (sys.argv) 23 | print("usage: "+args[0]+ " table_name hdfs_data_location hdfs_avro_schema_location [--partitions partitions] ") 24 | sys.exit(1) 25 | 26 | 27 | argNum = len(sys.argv) 28 | 29 | if (argNum < 4): 30 | usage(argNum) 31 | elif (argNum == 4): 32 | table_name = sys.argv[1] 33 | hdfs_data_location = sys.argv[2] 34 | hdfs_avro_schema_location = sys.argv[3] 35 | partitions = " " 36 | elif (argNum==6): 37 | table_name = sys.argv[1] 38 | hdfs_data_location = sys.argv[2] 39 | hdfs_avro_schema_location = sys.argv[3] 40 | partitions = "partitioned by " + sys.argv[5] 41 | else: 42 | usage(argNum) 43 | 44 | 45 | #schema_file = file('/tmp/'+args.table_name+'.schema','r') 46 | 47 | schema_obj = json.loads(read_schema_file(hdfs_avro_schema_location)) 48 | 49 | 50 | 51 | 52 | 53 | print """CREATE EXTERNAL TABLE %s 54 | %s 55 | %s 56 | ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' 57 | STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' 58 | OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' 59 | location '%s' 60 | TBLPROPERTIES ( 'avro.schema.url'='%s')""" % (table_name,gen_columns(schema_obj),partitions,hdfs_data_location,hdfs_avro_schema_location); 61 | -------------------------------------------------------------------------------- /daily_append.sh: -------------------------------------------------------------------------------- 1 | source common_env.sh 2 | 3 | [ $# -eq 0 ] && { echo "Usage: $0 table_name"; exit 1; } 4 | 5 | echo Step 0: Cleanup 6 | 7 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "drop table ${db_name}.${staging_table}" 2>&1 | grep FAIL 8 | 9 | echo Step 1: Execute Sqoop Job 10 | sqoop job -exec ${job_name} 2>&1 11 | 12 | echo Step 2: Add hive partition 13 | curr_year=`date +"%Y"` 14 | tmp=`date +"%m"` 15 | curr_month=${tmp#0} 16 | 17 | if beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "alter table ${partitioned_table} add if not exists partition (year=${curr_year},month=${curr_month})" 2>&1 | grep FAIL 18 | then 19 | echo Failed to create new partition. Cannot continue with data append. 20 | exit 1 21 | fi 22 | 23 | 24 | echo Step 3: Create staging table 25 | if beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "$(./gen_create_tbl.py ${staging_table} hdfs://nameservice1/${staging_dir}/${full_table_name} hdfs://nameservice1/${metadata_dir}/${schema_name})" 2>&1 | grep FAIL 26 | then 27 | echo Failed to create staging table. Cannot continue with merge. 28 | exit 1 29 | fi 30 | 31 | echo Step 4: Append data 32 | 33 | if beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" --hiveconf hive.exec.dynamic.partition.mode=nonstrict --hiveconf hive.exec.dynamic.partition=true -e " 34 | insert into table ${partitioned_table} partition (year,month) 35 | select *,year(from_unixtime(cast(round(${partition_column}/1000) as bigint))) as year,month(from_unixtime(cast(round(${partition_column}/1000) as bigint))) as month 36 | from ${db_name}.${staging_table}" 2>&1 | grep FAIL 37 | then 38 | echo Failed to insert new data into partitioned table. 39 | exit 1 40 | fi 41 | 42 | echo Step 5: Cleanup - drop staging table and move Sqooped data into Archive 43 | 44 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/webrep;principal=${KRB_PRINC}" -e "drop table ${db_name}.${staging_table}" 2>&1 | grep FAIL 45 | 46 | hdfs dfs -mv /${staging_dir}/${full_table_name} /${archive_dir}/${full_table_name}/`date +"%Y_%m_%d_%H_%M"` 47 | 48 | echo Step 6: Refresh Impala Metadata 49 | impala-shell -k -i pzxdap8priv -q "invalidate metadata ${db_name}.${partitioned_table}" 50 | 51 | echo Step 7: Validate 52 | impala-shell -k -i pzxdap8priv -q "select count(*) from ${db_name}.${partitioned_table}" 53 | -------------------------------------------------------------------------------- /initialize_table.sh: -------------------------------------------------------------------------------- 1 | ######## 2 | ## Initial sqooping and partitioning of a table 3 | ## This is intended to run once only per table !!! 4 | ## If re-running on the same table, the partitioned table needs to be dropped and the Sqoop job deleted. 5 | ## TODO: Partitioning will work right now only for timestamp column that will be partitioned by year and month. This needs serious generalization work 6 | ####### 7 | 8 | #set -e 9 | 10 | source common_env.sh 11 | 12 | [ $# -eq 0 ] && { echo "Usage: $0 table_name num_mappers"; exit 1; } 13 | 14 | echo Step 0: Cleanup 15 | sqoop job --delete ${job_name} 16 | hdfs dfs -rm /${metadata_dir}/${schema_name} 17 | hdfs dfs -rm -r /${top_dir}/${partitioned_table} 18 | hdfs dfs -rm -r /${staging_dir}/${full_table_name} 19 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "drop table ${db_name}.${partitioned_table}" 2>&1 | grep FAIL 20 | 21 | 22 | echo Step 1: Create Sqoop Job 23 | 24 | sqoop job --create ${job_name} --meta-connect ${sqoop_metastore} -- import --connect ${connect_string} --username ${user_name} --password-file ${password_file} --table ${full_table_name} -m ${mappers} --incremental append --check-column ${check_column} --as-avrodatafile --warehouse-dir /${staging_dir} 25 | 26 | echo Step 2: Execute Sqoop Job 27 | sqoop job -exec ${job_name} --meta-connect ${sqoop_metastore} 28 | 29 | echo Step 3: Extract AVRO schema and load to HDFS 30 | hadoop jar /opt/cloudera/parcels/CDH/lib/avro/avro-tools.jar getschema hdfs://nameservice1/${staging_dir}/${full_table_name}/part-m-00000.avro > /tmp/${schema_name} 31 | 32 | hdfs dfs -put /tmp/${schema_name} /${metadata_dir} 33 | 34 | echo Step 4: Create staging table and empty partitioned table 35 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "$(./gen_create_tbl.py ${staging_table} hdfs://nameservice1/${staging_dir}/${full_table_name} hdfs://nameservice1/${metadata_dir}/${schema_name})" 2>&1 | grep FAIL 36 | 37 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "$(./gen_create_tbl.py ${partitioned_table} hdfs://nameservice1/${top_dir}/${partitioned_table}/${curr_date} hdfs://nameservice1/${metadata_dir}/${schema_name} --partitions "(year int, month int)")" 2>&1 | grep FAIL 38 | 39 | echo Step 5: Move the data to the partitioned table 40 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" --hiveconf hive.exec.dynamic.partition.mode=nonstrict --hiveconf hive.exec.dynamic.partition=true -e "from ${db_name}.${staging_table} insert overwrite table ${db_name}.${partitioned_table} partition(year,month) select *,year(from_unixtime(cast(round(${partition_column}/1000) as bigint))),month(from_unixtime(cast(round(${partition_column}/1000) as bigint)));" 2>&1 | grep FAIL 41 | 42 | echo Step 6: Cleanup - drop staging table and move Sqooped data into Archive 43 | 44 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "drop table ${db_name}.${staging_table}" 2>&1 | grep FAIL 45 | 46 | hdfs dfs -mkdir /${archive_dir}/${full_table_name} 47 | hdfs dfs -mv /${staging_dir}/${full_table_name} /${archive_dir}/${full_table_name}/${curr_date} 48 | 49 | echo Step 7: Refresh Impala Metadata 50 | impala-shell -k -i ${IMPALAD} -q "invalidate metadata ${db_name}.${partitioned_table}" 51 | 52 | echo Step 8: Validate 53 | impala-shell -k -i ${IMPALAD} -q "select count(*) from ${db_name}.${partitioned_table}" 54 | echo All Done! 55 | -------------------------------------------------------------------------------- /daily_merge.sh: -------------------------------------------------------------------------------- 1 | source common_env.sh 2 | 3 | pk=${2-${table_name}_id} 4 | 5 | [ $# -eq 0 ] && { echo "Usage: $0 table_name [primary key]"; exit 1; } 6 | 7 | echo Step 0: Cleanup 8 | 9 | beeline -u "jdbc:hive2://${HIVESERVER}:1000/${db_name};principal=${KRB_PRINC}" -e "drop table ${db_name}.${staging_table}" 2>&1 | grep FAIL 10 | 11 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "drop table ${db_name}.${merged_table}" 2>&1 | grep FAIL 12 | 13 | echo Step 1: Execute Sqoop Job 14 | sqoop job -exec ${job_name} --meta-connect ${sqoop_metastore} 15 | 16 | echo Step 2: Create Staging Table 17 | if beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "$(./gen_create_tbl.py ${staging_table} hdfs://nameservice1/${staging_dir}/${full_table_name} hdfs://nameservice1/${metadata_dir}/${schema_name})" 2>&1 | grep FAIL 18 | then 19 | echo Failed to create staging table. Cannot continue with merge. 20 | exit 1 21 | fi 22 | 23 | echo Step 3: Create Merged Table 24 | 25 | if beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "$(./gen_create_tbl.py ${merged_table} hdfs://nameservice1/$top_dir/${partitioned_table}/${curr_date} hdfs://nameservice1/${metadata_dir}/${schema_name} --partitions "(year int, month int)")" 2>&1 | grep FAIL 26 | then 27 | echo Failed to create merged table. Cannot continue with merge. 28 | exit 1 29 | fi 30 | 31 | echo Step 4: Merge data from Partitioned table and Staging table into Merged table 32 | if beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" --hiveconf hive.exec.dynamic.partition.mode=nonstrict --hiveconf hive.exec.dynamic.partition=true -e " 33 | insert overwrite table ${db_name}.${merged_table} partition (year,month) 34 | select * from ( 35 | select /*+ MAPJOIN(new) */ existing.* from ${partitioned_table} existing 36 | left outer join 37 | (select * from ${staging_table}) new 38 | on existing.${pk} = new.${pk} 39 | where new.${pk} is null 40 | union all 41 | select new.*, year(from_unixtime(cast(round(${partition_column}/1000) as bigint))) as year,month(from_unixtime(cast(round(${partition_column}/1000) as bigint))) as month from ${staging_table} new ) T" 2>&1 | grep FAIL 42 | then 43 | echo Merge of new and existing data failed. Double check the primary keys and whether the schema was modified 44 | exit 1 45 | fi 46 | 47 | echo Step 5: Alter location of partitioned table to point to the new one 48 | # Dropping and re-creating table as a work around. Sentry requires too much privileges for alter table location 49 | #beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "alter table ${partitioned_table} set location 'hdfs://nameservice1/$top_dir/${partitioned_table}/${curr_date}'" 50 | 51 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "drop table ${partitioned_table}" 2>&1 | grep FAIL 52 | 53 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "$(./gen_create_tbl.py ${partitioned_table} hdfs://nameservice1/${top_dir}/${partitioned_table}/${curr_date} hdfs://nameservice1/${metadata_dir}/${schema_name} --partitions "(year int, month int)")" 2>&1 | grep FAIL 54 | 55 | beeline -u "jdbc:hive2://${HIVESERVER}:10000/${db_name};principal=${KRB_PRINC}" -e "msck repair table ${partitioned_table}" 2>&1 | grep FAIL 56 | 57 | echo Step 6: Move staging data to archive 58 | 59 | hdfs dfs -mv /${staging_dir}/${full_table_name} /${archive_dir}/${full_table_name}/${curr_date} 60 | 61 | echo Step 7: Refresh Impala Metadata 62 | impala-shell -k -i pzxdap8priv -q "invalidate metadata ${db_name}.${partitioned_table}" 63 | 64 | echo Step 8: Validate 65 | impala-shell -k -i pzxdap8priv -q "select count(*) from ${db_name}.${partitioned_table}" 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------