http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/sqlcomp/PrivMgrMD.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/PrivMgrMD.cpp b/core/sql/sqlcomp/PrivMgrMD.cpp index 811a71b..df0ca1c 100644 --- a/core/sql/sqlcomp/PrivMgrMD.cpp +++ b/core/sql/sqlcomp/PrivMgrMD.cpp @@ -159,24 +159,20 @@ PrivStatus PrivMgrMDAdmin::initializeComponentPrivileges() log(__FILE__, "initializing component privileges", -1); PrivStatus privStatus = STATUS_GOOD; - // First, let's start with a clean slate. Drop all components as well as - // their respective operations and and any privileges granted. This should be - // a NOP unless PrivMgr metadata was damaged and reintialization is occurring. - - PrivMgrComponents components(metadataLocation_,pDiags_); - components.dropAll(); - - // Next, register the component. - - privStatus = components.registerComponentInternal(SQL_OPERATION_NAME, - SQL_OPERATIONS_COMPONENT_UID, - true,"Component for SQL operations"); - - if (privStatus != STATUS_GOOD) - { + // First register the component. + PrivMgrComponents components(metadataLocation_,pDiags_); + bool componentExists = (components.exists(SQL_OPERATION_NAME)); + if (!componentExists) + { + privStatus = components.registerComponentInternal(SQL_OPERATION_NAME, + SQL_OPERATIONS_COMPONENT_UID, + true,"Component for SQL operations"); + if (privStatus != STATUS_GOOD) + { log(__FILE__, "ERROR: unable to register SQL_OPERATIONS component", -1); - return STATUS_ERROR; - } + return STATUS_ERROR; + } + } // Component is registered, now create all the operations associated with // the component. A grant from the system to the grantee (DB__ROOT) will @@ -197,7 +193,8 @@ std::string DB__ROOTName(ComUser::getRootUserName()); PrivMgr::getSQLOperationName(operation), codePtr,true, PrivMgr::getSQLOperationDescription(operation), - DB__ROOTID,DB__ROOTName,-1); + DB__ROOTID,DB__ROOTName,-1, + componentExists); if (privStatus == STATUS_GOOD) operationCodes.push_back(codePtr); @@ -221,7 +218,8 @@ PrivMgrComponentPrivileges componentPrivileges(metadataLocation_,pDiags_); ComUser::getRootUserID(), ComUser::getRootUserName(), ROOT_ROLE_ID, - DB__ROOTROLE,-1); + DB__ROOTROLE,-1, + componentExists); if (privStatus != STATUS_GOOD) { @@ -241,7 +239,8 @@ std::vector<std::string> CSOperationCodes; ComUser::getRootUserID(), ComUser::getRootUserName(), PUBLIC_USER, - PUBLIC_AUTH_NAME,0); + PUBLIC_AUTH_NAME,0, + componentExists); if (privStatus != STATUS_GOOD) { @@ -342,7 +341,6 @@ PrivStatus PrivMgrMDAdmin::initializeMetadata ( // If doesn't need upgrading - done // else - upgrade table bool populateObjectPrivs = false; - bool populateRoleGrants = false; try { @@ -385,8 +383,6 @@ PrivStatus PrivMgrMDAdmin::initializeMetadata ( if (tableDefinition.tableName == PRIVMGR_OBJECT_PRIVILEGES) populateObjectPrivs = true; - if (tableDefinition.tableName == PRIVMGR_ROLE_USAGE) - populateRoleGrants = true; } // upgrade tables @@ -406,7 +402,7 @@ PrivStatus PrivMgrMDAdmin::initializeMetadata ( // populate metadata tables PrivStatus privStatus = updatePrivMgrMetadata (objectsLocation,authsLocation, - populateObjectPrivs,populateRoleGrants); + populateObjectPrivs); // if error occurs, drop tables already created if (privStatus == STATUS_ERROR) @@ -560,13 +556,28 @@ PrivStatus PrivMgrMDAdmin::dropMetadata ( cliInterface.retrieveSQLDiagnostics(pDiags_); retcode = STATUS_ERROR; } + CmpSeabaseDDLrole role; - - role.dropStandardRole(DB__ROOTROLE); - role.dropStandardRole(DB__HIVEROLE); - role.dropStandardRole(DB__HBASEROLE); - log(__FILE__, "dropped roles DB__ROOTROLE, DB_HIVEROLE, DB_HBASEROLE", -1); - + std::vector<std::string> rolesCreated; + int32_t numberRoles = sizeof(systemRoles)/sizeof(SystemRolesStruct); + for (int32_t i = 0; i < numberRoles; i++) + { + const SystemRolesStruct &roleDefinition = systemRoles[i]; + + // special Auth includes roles that are not registered in the metadata + if (roleDefinition.isSpecialAuth) + continue; + + role.dropStandardRole(roleDefinition.roleName); + } + + int32_t actualSize = 0; + char buf[500]; + ComUser::getRoleList(buf, actualSize, 500); + buf[actualSize] = 0; + traceMsg = "dropped roles: "; + traceMsg + buf; + log(__FILE__, traceMsg, -1); //TODO: should notify QI log (__FILE__, "*** drop authorization completed ***", -1); @@ -1220,7 +1231,6 @@ int32_t diagsMark = pDiags_->mark(); return true; } - // ---------------------------------------------------------------------------- // method: compareTableDefs // @@ -1471,8 +1481,7 @@ static int32_t renameTable ( PrivStatus PrivMgrMDAdmin::updatePrivMgrMetadata( const std::string &objectsLocation, const std::string &authsLocation, - const bool shouldPopulateObjectPrivs, - const bool shouldPopulateRoleGrants) + const bool shouldPopulateObjectPrivs) { std::string traceMsg; @@ -1486,27 +1495,57 @@ PrivStatus PrivMgrMDAdmin::updatePrivMgrMetadata( return STATUS_ERROR; } - + // Create any roles. If this is an upgrade operation, some roles may + // already exist, just create any new roles. If this is an initialize + // operation, than all system roles are created. CmpSeabaseDDLrole role; - - role.createStandardRole(DB__ROOTROLE,ROOT_ROLE_ID); - role.createStandardRole(DB__HIVEROLE,HIVE_ROLE_ID); - role.createStandardRole(DB__HBASEROLE,HBASE_ROLE_ID); - log(__FILE__, "created roles DB__ROOTROLE, DB__HIVEROLE, and DB__HBASEROLE", -1); + std::vector<std::string> rolesCreated; + int32_t numberRoles = sizeof(systemRoles)/sizeof(SystemRolesStruct); + for (int32_t i = 0; i < numberRoles; i++) + { + const SystemRolesStruct &roleDefinition = systemRoles[i]; + + // special Auth includes roles that are not registered in the metadata + if (roleDefinition.isSpecialAuth) + continue; + + // returns true is role was created, false if it already existed + if (role.createStandardRole(roleDefinition.roleName, roleDefinition.roleID)) + rolesCreated.push_back(roleDefinition.roleName); + } + + // Report the number roles created + traceMsg = "created roles "; + char buf[MAX_AUTHNAME_LEN + 5]; + char sep = ' '; + for (size_t i = 0; i < rolesCreated.size(); i++) + { + sprintf(buf, "%c'%s' ", sep, rolesCreated[i].c_str()); + traceMsg.append(buf); + sep = ','; + } + log(__FILE__, traceMsg, -1); - if (shouldPopulateRoleGrants) + if (rolesCreated.size() > 0) { PrivMgrRoles role(" ",metadataLocation_,pDiags_); - privStatus = role.populateCreatorGrants(authsLocation); + privStatus = role.populateCreatorGrants(authsLocation, rolesCreated); if (privStatus != STATUS_GOOD) return STATUS_ERROR; } + + // If someone initializes authorization, creates some roles, then drops + // authorization, these roles exist in th system metadata (e.g. AUTHS table) + // but all usages are lost, including the initial creator grants. + // See if there are any roles that exist in AUTHS but do not have creator + // grants - probably should add creator grants. + // TBD - privStatus = initializeComponentPrivileges(); - - if (privStatus != STATUS_GOOD) - return STATUS_ERROR; + privStatus = initializeComponentPrivileges(); + + if (privStatus != STATUS_GOOD) + return STATUS_ERROR; // When new components and component operations are added // add an upgrade procedure
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/sqlcomp/PrivMgrMD.h ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/PrivMgrMD.h b/core/sql/sqlcomp/PrivMgrMD.h index a4c3f5e..c52a635 100644 --- a/core/sql/sqlcomp/PrivMgrMD.h +++ b/core/sql/sqlcomp/PrivMgrMD.h @@ -301,8 +301,7 @@ class PrivMgrMDAdmin : public PrivMgr PrivStatus updatePrivMgrMetadata( const std::string &objectsLocation, const std::string &authsLocation, - const bool shouldPopulateObjectPrivs, - const bool shouldPopulateRoleGrants); + const bool shouldPopulateObjectPrivs); PrivStatus upgradeMetadata ( const PrivMgrTableStruct &tableDefinition, http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/sqlcomp/PrivMgrRoles.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/PrivMgrRoles.cpp b/core/sql/sqlcomp/PrivMgrRoles.cpp index 9618f95..08489a1 100644 --- a/core/sql/sqlcomp/PrivMgrRoles.cpp +++ b/core/sql/sqlcomp/PrivMgrRoles.cpp @@ -40,6 +40,7 @@ // CmpCommon.h contains STMTHEAP declaration #include "CmpCommon.h" #include "CmpDDLCatErrorCodes.h" +#include "NAUserId.h" #include "ComUser.h" #include "ComSecurityKey.h" @@ -119,7 +120,9 @@ public: virtual PrivStatus insert(const PrivMgrMDRow &row); - PrivStatus insertSelect(const std::string & authsLocation); + PrivStatus insertSelect( + const std::string & authsLocation, + const std::string & inClause); PrivStatus selectAllWhere( const std::string & whereClause, @@ -1296,7 +1299,9 @@ PrivStatus privStatus = myTable.selectCountWhere(whereClause,rowCount); // * the diags area. * // * * // ***************************************************************************** -PrivStatus PrivMgrRoles::populateCreatorGrants(const std::string & authsLocation) +PrivStatus PrivMgrRoles::populateCreatorGrants( + const std::string & authsLocation, + const std::vector<std::string> &rolesToAdd) { @@ -1305,22 +1310,28 @@ PrivStatus PrivMgrRoles::populateCreatorGrants(const std::string & authsLocation MyTable &myTable = static_cast<MyTable &>(myTable_); - // See if the table is empty before inserting any rows + int32_t numberRoles = sizeof(systemRoles)/sizeof(SystemRolesStruct) - + NUMBER_SPECIAL_SYSTEM_ROLES; + + // Calculate the number of roles that have already been created + int64_t expectedRows = numberRoles - rolesToAdd.size(); std::string whereClause; - int64_t expectedRows = 0; + int64_t foundRows = 0; - PrivStatus privStatus = myTable.selectCountWhere(whereClause,expectedRows); + PrivStatus privStatus = myTable.selectCountWhere(whereClause,foundRows); if (privStatus == STATUS_ERROR) return privStatus; - if (expectedRows != 0) + if (foundRows != expectedRows) { std::string message ("Found "); + message += to_string((long long int)foundRows); + message += " rows in ROLE_USAGE table, expecting "; message += to_string((long long int)expectedRows); - message += " rows in ROLE_USAGE table, expecting 0 rows"; + message += " rows"; traceMsg = "ERROR: "; traceMsg += message; PrivMgr::log(__FILE__, message, -1); @@ -1329,7 +1340,19 @@ PrivStatus PrivMgrRoles::populateCreatorGrants(const std::string & authsLocation } // insert the rows - privStatus = myTable.insertSelect(authsLocation); + std::string inClause (" auth_db_name in ("); + std::string sep = ""; + for (size_t i = 0; i < rolesToAdd.size(); i++) + { + inClause.append(sep); + inClause.append ("'"); + inClause.append(rolesToAdd[i]); + inClause.append ("'"); + sep = ","; + } + inClause += ")"; + + privStatus = myTable.insertSelect(authsLocation, inClause); if (privStatus == STATUS_ERROR) { @@ -1340,7 +1363,7 @@ PrivStatus PrivMgrRoles::populateCreatorGrants(const std::string & authsLocation return privStatus; } - // make sure that the number rows inserted match the expected. + // make sure that the number rows inserted match the total. // get the number of rows inserted int64_t insertedRows; @@ -1352,7 +1375,17 @@ PrivStatus PrivMgrRoles::populateCreatorGrants(const std::string & authsLocation // get number rows expected std::string selectStmt ("SELECT COUNT(*) FROM "); - whereClause = " where AUTH_TYPE = 'R'"; + int32_t actualSize = 0; + char buf[500]; + if (ComUser::getRoleList(buf, actualSize, 500)) + { + PRIVMGR_INTERNAL_ERROR("internal error getting role list"); + return STATUS_ERROR; + } + whereClause = " where AUTH_TYPE = 'R' AND AUTH_DB_NAME IN ("; + whereClause += buf; + whereClause += ")"; + selectStmt += authsLocation; selectStmt += " "; selectStmt += whereClause; @@ -1371,9 +1404,9 @@ PrivStatus PrivMgrRoles::populateCreatorGrants(const std::string & authsLocation } // Check to see if rows inserted match expected rows - if (expectedRows != insertedRows) + if (numberRoles != insertedRows) { - std::string message ("Expected to insert "); + std::string message ("Expected to find "); message += to_string((long long int)expectedRows); message += " rows into ROLE_USAGE table, instead "; message += to_string((long long int)insertedRows); @@ -1885,7 +1918,9 @@ char grantorAuthClass[3] = {0}; // * *: Insert failed. A CLI error is put into the diags area. * // * * // ***************************************************************************** -PrivStatus MyTable::insertSelect(const std::string & authsLocation) +PrivStatus MyTable::insertSelect( + const std::string & authsLocation, + const std::string & inClause) { @@ -1894,9 +1929,9 @@ char insertStatement[2000]; sprintf(insertStatement, "INSERT INTO %s SELECT A1.AUTH_ID, A1.AUTH_DB_NAME, A1.AUTH_CREATOR," "(SELECT AUTH_DB_NAME FROM %s A2 WHERE A2.auth_ID = A1.AUTH_CREATOR)," "(SELECT AUTH_TYPE FROM %s A3 WHERE A3.auth_ID = A1.AUTH_CREATOR)," - "-2,'_SYSTEM','%c',-1 FROM %s A1 WHERE A1.AUTH_TYPE = 'R'", + "-2,'_SYSTEM','%c',-1 FROM %s A1 WHERE A1.AUTH_TYPE = 'R' AND %s", tableName_.c_str(),authsLocation.c_str(),authsLocation.c_str(), - 'U',authsLocation.c_str()); + 'U',authsLocation.c_str(), inClause.c_str()); return CLIImmediate(insertStatement); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/sqlcomp/PrivMgrRoles.h ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/PrivMgrRoles.h b/core/sql/sqlcomp/PrivMgrRoles.h index eb8000b..052ce6e 100644 --- a/core/sql/sqlcomp/PrivMgrRoles.h +++ b/core/sql/sqlcomp/PrivMgrRoles.h @@ -93,7 +93,9 @@ public: bool isUserGrantedAnyRole(const int32_t authID); - PrivStatus populateCreatorGrants(const std::string &authsLocation); + PrivStatus populateCreatorGrants( + const std::string &authsLocation, + const std::vector<std::string> &rolesToAdd); PrivStatus revokeRole( const std::vector<int32_t> & roleIDs, http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/sqlcomp/nadefaults.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp index 37d740f..5d3d08b 100644 --- a/core/sql/sqlcomp/nadefaults.cpp +++ b/core/sql/sqlcomp/nadefaults.cpp @@ -2073,12 +2073,16 @@ SDDkwd__(ISO_MAPPING, (char *)SQLCHARSETSTRING_ISO88591), // precision but degraded performance. SDDkwd__(LIMIT_MAX_NUMERIC_PRECISION, "SYSTEM"), + // Size in bytes used to perform garbage collection to lob data file + // default size is 5GB . Change to adjust disk usage. + DDint__(LOB_GC_LIMIT_SIZE, "5000"), + DDint__(LOB_HDFS_PORT, "0"), DD_____(LOB_HDFS_SERVER, "default"), - + // Size of memoryin bytes used to perform I/O to lob data file // default size is 512MB . Change to adjust memory usage. - DDint__(LOB_MAX_CHUNK_MEM_SIZE, "536870912"), + DDint__(LOB_MAX_CHUNK_MEM_SIZE, "512"), // default size is 10 G (10000 M) DDint__(LOB_MAX_SIZE, "10000"), // default size is 32000. Change this to extract more data into memory. @@ -3295,28 +3299,30 @@ XDDkwd__(SUBQUERY_UNNESTING, "ON"), DDint__(TEST_PASS_ONE_ASSERT_TASK_NUMBER, "-1"), DDint__(TEST_PASS_TWO_ASSERT_TASK_NUMBER, "-1"), - XDDintN2(TIMEOUT, "6000"), + XDDintN2(TIMEOUT, "6000"), - DDflt0_(TMUDF_CARDINALITY_FACTOR, "1"), - DDflt0_(TMUDF_LEAF_CARDINALITY, "1"), + DDflt0_(TMUDF_CARDINALITY_FACTOR, "1"), + DDflt0_(TMUDF_LEAF_CARDINALITY, "1"), DDkwd__(TOTAL_RESOURCE_COSTING, "ON"), - + DDint__(TRAF_ALIGNED_FORMAT_ADD_COL_METHOD, "2"), - - DDkwd__(TRAF_ALIGNED_ROW_FORMAT, "OFF"), - + + DDkwd__(TRAF_ALIGNED_ROW_FORMAT, "OFF"), + DDkwd__(TRAF_ALLOW_ESP_COLOCATION, "OFF"), + + DDkwd__(TRAF_ALLOW_RESERVED_COLNAMES, "OFF"), + + DDkwd__(TRAF_ALLOW_SELF_REF_CONSTR, "ON"), - DDkwd__(TRAF_ALLOW_SELF_REF_CONSTR, "ON"), - - DDkwd__(TRAF_ALTER_COL_ATTRS, "ON"), + DDkwd__(TRAF_ALTER_COL_ATTRS, "ON"), - DDkwd__(TRAF_BLOB_AS_VARCHAR, "ON"), //set to OFF to enable Lobs support + DDkwd__(TRAF_BLOB_AS_VARCHAR, "ON"), //set to OFF to enable Lobs support - DDkwd__(TRAF_BOOTSTRAP_MD_MODE, "OFF"), + DDkwd__(TRAF_BOOTSTRAP_MD_MODE, "OFF"), - DDkwd__(TRAF_CLOB_AS_VARCHAR, "ON"), //set to OFF to enable Lobs support + DDkwd__(TRAF_CLOB_AS_VARCHAR, "ON"), //set to OFF to enable Lobs support DDkwd__(TRAF_COL_LENGTH_IS_CHAR, "ON"), @@ -6983,6 +6989,10 @@ DefaultToken NADefaults::token(Int32 attrEnum, isValid = TRUE; break; + case LOB_GC_LIMIT_SIZE: + if (tok >= 0 ) + isValid=TRUE; + case TRAF_TRANS_TYPE: if (tok == DF_MVCC || tok == DF_SSCC) isValid = TRUE; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/ustat/hs_cli.cpp ---------------------------------------------------------------------- diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp index 7af4584..de94da3 100644 --- a/core/sql/ustat/hs_cli.cpp +++ b/core/sql/ustat/hs_cli.cpp @@ -4762,7 +4762,7 @@ Lng32 HSinsertEmptyHist::insert() #else // NA_USTAT_USE_STATIC not defined, use dynamic query char sbuf[25]; NAString qry = "SELECT HISTOGRAM_ID, COL_POSITION, COLUMN_NUMBER, COLCOUNT, " - "cast(READ_TIME as char(19)), REASON " + "cast(READ_TIME as char(19) character set iso88591), REASON " "FROM "; qry.append(histTable_); qry.append( " WHERE TABLE_UID = "); @@ -5479,7 +5479,7 @@ static char ppStmtText[] = " when LEFT_CHILD_SEQ_NUM is null then" " '. '" " else" -" cast(cast(LEFT_CHILD_SEQ_NUM as numeric(3)) as char(3))" +" cast(cast(LEFT_CHILD_SEQ_NUM as numeric(3)) as char(3) character set iso88591)" " end" "" // RIGHT CHILD @@ -5487,11 +5487,11 @@ static char ppStmtText[] = " when RIGHT_CHILD_SEQ_NUM is null then" " '. '" " else" -" cast(cast(RIGHT_CHILD_SEQ_NUM as numeric(3)) as char(3))" +" cast(cast(RIGHT_CHILD_SEQ_NUM as numeric(3)) as char(3) character set iso88591)" " end" "" // SEQUENCE NUMBER -" , cast(cast(SEQ_NUM as numeric(3)) as char(3))" +" , cast(cast(SEQ_NUM as numeric(3)) as char(3) character set iso88591)" "" // OPERATOR " , cast(substring(lower(OPERATOR) from 1 for 20) as char(20))" @@ -5722,13 +5722,13 @@ static char ppStmtText[] = " from 1 for 20) as char(20))" "" // CARDINALITY -" , CAST(CARDINALITY AS CHAR(11))" +" , CAST(CARDINALITY AS CHAR(11) character set iso88591)" "" // OPERATOR COST -" , CAST(OPERATOR_COST AS CHAR(11))" +" , CAST(OPERATOR_COST AS CHAR(11) character set iso88591)" "" // TOTAL COST -" , CAST(TOTAL_COST AS CHAR(11))" +" , CAST(TOTAL_COST AS CHAR(11) character set iso88591)" "" " FROM TABLE(EXPLAIN(NULL, '"; @@ -5751,6 +5751,8 @@ Lng32 printPlan(SQLSTMT_ID *stmt) HSLogMan *LM = HSLogMan::Instance(); + HSFuncExecQuery("CQD DEFAULT_CHARSET 'ISO88591'"); // to avoid buffer overruns in row + NAString ppStmtStr = ppStmtText; ppStmtStr.append((char *)stmt->identifier).append("')) ORDER BY SEQ_NUM DESC;"); @@ -5794,11 +5796,15 @@ Lng32 printPlan(SQLSTMT_ID *stmt) LM->Log(LM->msg); } else if (retcode != 100) - HSLogError(retcode); + { + HSFuncExecQuery("CQD DEFAULT_CHARSET RESET"); + HSLogError(retcode); + } } // ppStmtId will be closed by ~HSCursor if closeStmtNeeded_ is set. + HSFuncExecQuery("CQD DEFAULT_CHARSET RESET"); return retcode; } http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/core/sql/ustat/hs_globals.cpp ---------------------------------------------------------------------- diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp index ff984e1..c323865 100644 --- a/core/sql/ustat/hs_globals.cpp +++ b/core/sql/ustat/hs_globals.cpp @@ -7743,7 +7743,7 @@ Lng32 HSGlobalsClass::groupListFromTable(HSColGroupStruct*& groupList, #else // NA_USTAT_USE_STATIC not defined, use dynamic query char sbuf[25]; NAString qry = "SELECT HISTOGRAM_ID, COL_POSITION, COLUMN_NUMBER, COLCOUNT, " - "cast(READ_TIME as char(19)), REASON " + "cast(READ_TIME as char(19) character set iso88591), REASON " "FROM "; qry.append(hstogram_table->data()); qry.append( " WHERE TABLE_UID = "); http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/Makefile ---------------------------------------------------------------------- diff --git a/dcs/Makefile b/dcs/Makefile index 715e6ed..9245415 100644 --- a/dcs/Makefile +++ b/dcs/Makefile @@ -52,6 +52,8 @@ LICENSE: ../licenses/LICENSE-dcs NOTICE: ../NOTICE cp -f $? $@ + # Add notice file from jython 2.5.3 + cat ../licenses/not-dcs-bin >> $@ clean: -$(MAVEN) clean | grep ERROR http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/bin/dcs ---------------------------------------------------------------------- diff --git a/dcs/bin/dcs b/dcs/bin/dcs index 5c506fe..84246d0 100755 --- a/dcs/bin/dcs +++ b/dcs/bin/dcs @@ -21,26 +21,6 @@ # #* @@@ END COPYRIGHT @@@ # */ -#/** -# * Copyright 2007 The Apache Software Foundation -# * -# * Licensed to the Apache Software Foundation (ASF) under one -# * or more contributor license agreements. See the NOTICE file -# * distributed with this work for additional information -# * regarding copyright ownership. The ASF licenses this file -# * to you under the Apache License, Version 2.0 (the -# * "License"); you may not use this file except in compliance -# * with the License. You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# */ -# # The dcs command script. # # Environment Variables: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/bin/dcs-config.sh ---------------------------------------------------------------------- diff --git a/dcs/bin/dcs-config.sh b/dcs/bin/dcs-config.sh index 023521a..aec9e57 100755 --- a/dcs/bin/dcs-config.sh +++ b/dcs/bin/dcs-config.sh @@ -21,27 +21,6 @@ # # @@@ END COPYRIGHT @@@ # */ # -#/** -# * Copyright 2007 The Apache Software Foundation -# * -# * Licensed to the Apache Software Foundation (ASF) under one -# * or more contributor license agreements. See the NOTICE file -# * distributed with this work for additional information -# * regarding copyright ownership. The ASF licenses this file -# * to you under the Apache License, Version 2.0 (the -# * "License"); you may not use this file except in compliance -# * with the License. You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# */ - -# # should not be executable directly # also should not be passed any arguments, since we need original $* http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/bin/dcs-daemon.sh ---------------------------------------------------------------------- diff --git a/dcs/bin/dcs-daemon.sh b/dcs/bin/dcs-daemon.sh index 0061aec..530d356 100755 --- a/dcs/bin/dcs-daemon.sh +++ b/dcs/bin/dcs-daemon.sh @@ -21,27 +21,6 @@ # # @@@ END COPYRIGHT @@@ # */ -# -#/** -# * Copyright 2007 The Apache Software Foundation -# * -# * Licensed to the Apache Software Foundation (ASF) under one -# * or more contributor license agreements. See the NOTICE file -# * distributed with this work for additional information -# * regarding copyright ownership. The ASF licenses this file -# * to you under the Apache License, Version 2.0 (the -# * "License"); you may not use this file except in compliance -# * with the License. You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# */ -# # Runs a DCS command as a daemon. # # Environment Variables http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/bin/dcs-daemons.sh ---------------------------------------------------------------------- diff --git a/dcs/bin/dcs-daemons.sh b/dcs/bin/dcs-daemons.sh index 09fc671..1af1cad 100755 --- a/dcs/bin/dcs-daemons.sh +++ b/dcs/bin/dcs-daemons.sh @@ -22,26 +22,6 @@ # @@@ END COPYRIGHT @@@ # */ # -#/** -# * Copyright 2007 The Apache Software Foundation -# * -# * Licensed to the Apache Software Foundation (ASF) under one -# * or more contributor license agreements. See the NOTICE file -# * distributed with this work for additional information -# * regarding copyright ownership. The ASF licenses this file -# * to you under the Apache License, Version 2.0 (the -# * "License"); you may not use this file except in compliance -# * with the License. You may obtain a copy of the License at -# * -# * http://www.apache.org/licenses/LICENSE-2.0 -# * -# * Unless required by applicable law or agreed to in writing, software -# * distributed under the License is distributed on an "AS IS" BASIS, -# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# * See the License for the specific language governing permissions and -# * limitations under the License. -# */ -# usage="Usage: dcs-daemons.sh [--config <dcs-confdir>] \ [--hosts serversfile] [start|stop] command args..." http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/pom.xml ---------------------------------------------------------------------- diff --git a/dcs/pom.xml b/dcs/pom.xml index 1fb2938..e9b6d11 100644 --- a/dcs/pom.xml +++ b/dcs/pom.xml @@ -86,9 +86,9 @@ </releases> </repository> <repository> - <id>codehaus</id> - <name>Codehaus Public</name> - <url>http://repository.codehaus.org/</url> + <id>codehaus-mule</id> + <name>Codehaus Mule Public</name> + <url>https://repository-master.mulesoft.org/nexus/content/groups/public/</url> <snapshots> <enabled>false</enabled> </snapshots> @@ -182,13 +182,6 @@ outputdir="${generated.sources}/java" package="org.trafodion.dcs.generated.server" webxml="${build.webapps}/server/WEB-INF/web.xml"/> -<!-- - <mkdir dir="${build.webapps}/rest/WEB-INF"/> - <jspcompiler uriroot="${src.webapps}/rest" - outputdir="${generated.sources}/java" - package="org.trafodion.dcs.generated.rest" - webxml="${build.webapps}/rest/WEB-INF/web.xml"/> ---> <exec executable="sh"> <arg line="${basedir}/src/saveVersion.sh ${project.version} ${generated.sources}/java"/> </exec> @@ -498,7 +491,7 @@ <compileSource>1.6</compileSource> <!-- Dependencies --> - <hadoop.version>2.6.0</hadoop.version> + <hadoop.version>${env.HADOOP_DEP_VER}</hadoop.version> <commons-cli.version>1.2</commons-cli.version> <commons-codec.version>1.4</commons-codec.version> <commons-io.version>2.1</commons-io.version> @@ -508,7 +501,7 @@ <commons-configuration.version>1.6</commons-configuration.version> <metrics-core.version>2.1.2</metrics-core.version> <guava.version>11.0.2</guava.version> - <jackson.version>1.8.8</jackson.version> + <jackson.version>1.9.13</jackson.version> <jasper.version>5.5.23</jasper.version> <jamon.runtime.version>2.4.0</jamon.runtime.version> <jaxb-api.version>2.1</jaxb-api.version> @@ -516,7 +509,7 @@ <jetty.jspapi.version>6.1.14</jetty.jspapi.version> <jersey.version>1.8</jersey.version> <junit.version>4.10</junit.version> - <slf4j.version>1.4.3</slf4j.version> + <slf4j.version>1.4.3</slf4j.version> <log4j.version>1.2.16</log4j.version> <zookeeper.version>3.4.5</zookeeper.version> <jython-standalone.version>2.5.3</jython-standalone.version> @@ -566,16 +559,6 @@ </dependency> <!-- General dependencies --> - <dependency> - <groupId>com.yammer.metrics</groupId> - <artifactId>metrics-core</artifactId> - <version>${metrics-core.version}</version> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>${guava.version}</version> - </dependency> <dependency> <groupId>org.python</groupId> <artifactId>jython-standalone</artifactId> @@ -587,26 +570,11 @@ <version>${commons-cli.version}</version> </dependency> <dependency> - <groupId>commons-configuration</groupId> - <artifactId>commons-configuration</artifactId> - <version>${commons-configuration.version}</version> - </dependency> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - <version>${commons-codec.version}</version> - </dependency> - <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>${commons-io.version}</version> </dependency> <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>${commons-lang.version}</version> - </dependency> - <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>${commons-logging.version}</version> @@ -671,34 +639,14 @@ <version>${jetty.jspapi.version}</version> </dependency> <dependency> - <groupId>org.mortbay.jetty</groupId> - <artifactId>servlet-api-2.5</artifactId> - <version>${jetty.jspapi.version}</version> + <groupId>displaytag</groupId> + <artifactId>displaytag</artifactId> + <version>${displaytag.version}</version> </dependency> <!-- While jackson is also a dependency of both jersey and avro, these can bring in jars from different, incompatible versions. We force the same version with these dependencies --> <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-core-asl</artifactId> - <version>${jackson.version}</version> - </dependency> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-mapper-asl</artifactId> - <version>${jackson.version}</version> - </dependency> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-jaxrs</artifactId> - <version>${jackson.version}</version> - </dependency> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-xc</artifactId> - <version>${jackson.version}</version> - </dependency> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> @@ -708,98 +656,13 @@ <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> - <dependency> - <!--If this is not in the runtime lib, we get odd - "2009-02-27 11:38:39.504::WARN: failed jsp - java.lang.NoSuchFieldError: IS_SECURITY_ENABLED" - exceptions out of jetty deploying webapps. - St.Ack Thu May 20 01:04:41 PDT 2010 - --> - <groupId>tomcat</groupId> - <artifactId>jasper-compiler</artifactId> - <version>${jasper.version}</version> - <scope>runtime</scope> - <exclusions> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>jsp-api</artifactId> - </exclusion> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - </exclusion> - <exclusion> - <groupId>ant</groupId> - <artifactId>ant</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>tomcat</groupId> - <artifactId>jasper-runtime</artifactId> - <version>${jasper.version}</version> - <scope>runtime</scope> - <exclusions> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>jsp-api</artifactId> - </exclusion> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - </exclusion> - </exclusions> - </dependency> + <dependency> <groupId>org.jamon</groupId> <artifactId>jamon-runtime</artifactId> <version>${jamon.runtime.version}</version> </dependency> - - <!-- REST dependencies --> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-core</artifactId> - <version>${jersey.version}</version> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-json</artifactId> - <version>${jersey.version}</version> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-server</artifactId> - <version>${jersey.version}</version> - </dependency> - <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> - <version>${jaxb-api.version}</version> - <exclusions> - <exclusion> - <groupId>javax.xml.stream</groupId> - <artifactId>stax-api</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.codehaus.jettison</groupId> - <artifactId>jettison</artifactId> - <version>${jettison.version}</version> - </dependency> - <dependency> - <groupId>displaytag</groupId> - <artifactId>displaytag</artifactId> - <version>${displaytag.version}</version> - </dependency> - <dependency> - <groupId>displaytag</groupId> - <artifactId>displaytag-export-poi</artifactId> - <version>${displaytag.version}</version> - </dependency> </dependencies> - <profiles> <!-- JDBC drivers needed for compile, but not site docs This allows turning off dependency on command line (-P '!jdbc') --> http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/assembly/all.xml ---------------------------------------------------------------------- diff --git a/dcs/src/assembly/all.xml b/dcs/src/assembly/all.xml index 34f2636..391cf11 100644 --- a/dcs/src/assembly/all.xml +++ b/dcs/src/assembly/all.xml @@ -78,10 +78,13 @@ <outputDirectory>/lib</outputDirectory> <unpack>false</unpack> <scope>runtime</scope> - <excludes> - <exclude>tomcat:jasper-runtime</exclude> - <exclude>org.trafodion:dcs</exclude> - </excludes> + <includes> + <include>displaytag:displaytag</include> + <include>org.python:jython-standalone</include> + <include>org.slf4j:slf4j-log4j12</include> + <include>org.slf4j:slf4j-api</include> + <include>org.mortbay.jetty</include> + </includes> <fileMode>0644</fileMode> <directoryMode>0644</directoryMode> </dependencySet> http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java b/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java index 1c35065..719c3d3 100644 --- a/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java +++ b/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java @@ -61,7 +61,6 @@ import org.trafodion.dcs.util.VersionInfo; import org.trafodion.dcs.zookeeper.ZkClient; import org.trafodion.dcs.zookeeper.ZKConfig; import org.trafodion.dcs.master.listener.ListenerService; -import org.trafodion.dcs.rest.DcsRest; public class DcsMaster implements Runnable { private static final Log LOG = LogFactory.getLog(DcsMaster.class); @@ -74,7 +73,6 @@ public class DcsMaster implements Runnable { private int port; private int portRange; private InfoServer infoServer; - private DcsRest restServer; private String serverName; private int infoPort; private long startTime; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java b/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java index 6b02123..4a031b8 100644 --- a/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java +++ b/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java @@ -19,27 +19,7 @@ specific language governing permissions and limitations under the License. * @@@ END COPYRIGHT @@@ - */ -/** - * Copyright 2007 The Apache Software Foundation - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +*/ package org.trafodion.dcs.master; import java.io.IOException; http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/DcsRest.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/DcsRest.java b/dcs/src/main/java/org/trafodion/dcs/rest/DcsRest.java deleted file mode 100644 index 046b308..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/DcsRest.java +++ /dev/null @@ -1,215 +0,0 @@ -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -/** - * Copyright 2011 The Apache Software Foundation - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.trafodion.dcs.rest; - -import java.util.List; -import java.util.ArrayList; -import java.io.IOException; -import java.lang.InterruptedException; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.PosixParser; -import org.apache.commons.cli.ParseException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.net.DNS; - -import org.trafodion.dcs.util.DcsConfiguration; -import org.trafodion.dcs.util.Strings; -import org.trafodion.dcs.util.VersionInfo; - -import org.mortbay.jetty.Connector; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.nio.SelectChannelConnector; -import org.mortbay.jetty.servlet.Context; -import org.mortbay.jetty.servlet.ServletHolder; -import org.mortbay.thread.QueuedThreadPool; - -import com.sun.jersey.spi.container.servlet.ServletContainer; - -public class DcsRest implements Runnable, RestConstants { - private static final Log LOG = LogFactory.getLog(DcsRest.class.getName()); - private Configuration conf; - private Thread thrd; - private String[] args; - private RESTServlet servlet; - - private static void printUsageAndExit(Options options, int exitCode) { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("bin/dcs rest start", "", options, - "\nTo run the REST server as a daemon, execute " + - "bin/dcs-daemon.sh start|stop rest [--infoport <port>] [-p <port>] [-ro]\n", true); - System.exit(exitCode); - } - - public DcsRest(String[] args) { - this.args = args; - conf = DcsConfiguration.create(); - - Options options = new Options(); - options.addOption("p", "port", true, "Port to bind to [default: 8080]"); - options.addOption("ro", "readonly", false, "Respond only to GET HTTP " + - "method requests [default: false]"); - options.addOption(null, "infoport", true, "Port for web UI"); - - try { - servlet = RESTServlet.getInstance(conf); - } catch (IOException e) { - LOG.error("Exception " + e); - e.printStackTrace(); - } - - CommandLine commandLine = null; - try { - commandLine = new PosixParser().parse(options, args); - } catch (ParseException e) { - LOG.error("Could not parse: ", e); - printUsageAndExit(options, -1); - } - - // check for user-defined port setting, if so override the conf - if (commandLine != null && commandLine.hasOption("port")) { - String val = commandLine.getOptionValue("port"); - servlet.getConfiguration().setInt("dcs.rest.port", Integer.valueOf(val)); - LOG.debug("port set to " + val); - } - - // check if server should only process GET requests, if so override the conf - if (commandLine != null && commandLine.hasOption("readonly")) { - servlet.getConfiguration().setBoolean("dcs.rest.readonly", true); - LOG.debug("readonly set to true"); - } - - // check for user-defined info server port setting, if so override the conf - if (commandLine != null && commandLine.hasOption("infoport")) { - String val = commandLine.getOptionValue("infoport"); - servlet.getConfiguration().setInt("dcs.rest.info.port", Integer.valueOf(val)); - LOG.debug("Web UI port set to " + val); - } - - @SuppressWarnings("unchecked") - List<String> remainingArgs = commandLine != null ? commandLine.getArgList() : new ArrayList<String>(); - if (remainingArgs.size() != 1) { - printUsageAndExit(options, 1); - } - - String command = remainingArgs.get(0); - if ("start".equals(command)) { - // continue and start container - } else if ("stop".equals(command)) { - System.exit(1); - } else { - printUsageAndExit(options, 1); - } - - thrd = new Thread(this); - thrd.start(); - } - - public DcsRest(Configuration conf) { - try { - servlet = RESTServlet.getInstance(conf); - } catch (IOException e) { - LOG.error("Exception " + e); - e.printStackTrace(); - return; - } - - thrd = new Thread(this); - thrd.start(); - } - - public void run() { - VersionInfo.logVersion(); - - // set up the Jersey servlet container for Jetty - ServletHolder sh = new ServletHolder(ServletContainer.class); - sh.setInitParameter( - "com.sun.jersey.config.property.resourceConfigClass", - ResourceConfig.class.getCanonicalName()); - sh.setInitParameter("com.sun.jersey.config.property.packages","org.trafodion.dcs.rest"); - - // set up Jetty and run the embedded server - Server server = new Server(); - - Connector connector = new SelectChannelConnector(); - connector.setPort(servlet.getConfiguration().getInt("dcs.rest.port", 8080)); - connector.setHost(servlet.getConfiguration().get("dcs.rest.host", "0.0.0.0")); - - server.addConnector(connector); - - // Set the default max thread number to 100 to limit - // the number of concurrent requests so that REST server doesn't OOM easily. - // Jetty set the default max thread number to 250, if we don't set it. - // - // Our default min thread number 2 is the same as that used by Jetty. - int maxThreads = servlet.getConfiguration().getInt("dcs.rest.threads.max", 100); - int minThreads = servlet.getConfiguration().getInt("dcs.rest.threads.min", 2); - QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads); - threadPool.setMinThreads(minThreads); - server.setThreadPool(threadPool); - server.setSendServerVersion(false); - server.setSendDateHeader(false); - server.setStopAtShutdown(true); - - Context context = new Context(server, "/", Context.SESSIONS); - context.addServlet(sh, "/*"); - - try { - server.start(); - server.join(); - } catch (InterruptedException e) { - LOG.error("InterruptedException " + e); - } catch (Exception e) { - LOG.error("Exception " + e); - } - } - - public static void main(String[] args) throws Exception { - DcsRest server = new DcsRest(args); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/GetStatusResponse.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/GetStatusResponse.java b/dcs/src/main/java/org/trafodion/dcs/rest/GetStatusResponse.java deleted file mode 100644 index c8ee6c4..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/GetStatusResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -package org.trafodion.dcs.rest; - -import java.io.IOException; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlElement; - -@XmlRootElement -public class GetStatusResponse { - private String workloadId; - - public GetStatusResponse(){ - }; - - public GetStatusResponse(String value){ - workloadId = value; - }; - - @XmlElement - public String getWorkloadId() { - return workloadId; - } - - public void setWorkloadId(String value) { - this.workloadId = value; - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/RESTServlet.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/RESTServlet.java b/dcs/src/main/java/org/trafodion/dcs/rest/RESTServlet.java deleted file mode 100644 index 13016b4..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/RESTServlet.java +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -/** - * Copyright 2007 The Apache Software Foundation - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.trafodion.dcs.rest; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.StringTokenizer; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.HashMap; -import java.util.Map; - -import org.trafodion.dcs.Constants; -import org.trafodion.dcs.rest.ServerConnector; -import org.trafodion.dcs.rest.RestConstants; -import org.trafodion.dcs.zookeeper.ZkClient; - -import org.apache.zookeeper.KeeperException; -import org.apache.zookeeper.data.Stat; -import org.apache.zookeeper.ZooDefs; - -import org.apache.hadoop.conf.Configuration; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -/** - * Singleton class encapsulating global REST servlet state and functions. - */ -public class RESTServlet implements RestConstants { - private static final Log LOG = LogFactory.getLog(RESTServlet.class); - private static RESTServlet INSTANCE; - private final Configuration conf; - private static ZkClient zkc; - private String parentZnode; - private Map<String, ServerConnector> m = new HashMap<String, ServerConnector>(); - - /** - * @return the RESTServlet singleton instance - * @throws IOException - */ - public synchronized static RESTServlet getInstance() - throws IOException { - assert(INSTANCE != null); - return INSTANCE; - } - - /** - * @param conf Existing configuration to use in rest servlet - * @return the RESTServlet singleton instance - * @throws IOException - */ - public synchronized static RESTServlet getInstance(Configuration conf) - throws IOException { - if (INSTANCE == null) { - INSTANCE = new RESTServlet(conf); - } - return INSTANCE; - } - - public ZkClient getZk(){ - return this.zkc; - } - - public String getParentZnode(){ - return this.parentZnode; - } - - public synchronized static void stop() { - if (INSTANCE != null) INSTANCE = null; - } - - /** - * Constructor with existing configuration - * @param conf existing configuration - * @throws IOException. - */ - RESTServlet(Configuration conf) throws IOException { - this.conf = conf; - this.parentZnode = conf.get(Constants.ZOOKEEPER_ZNODE_PARENT,Constants.DEFAULT_ZOOKEEPER_ZNODE_PARENT); - - } - - private void openZk() throws IOException { - try { - if(zkc == null) - zkc = new ZkClient();//CTRL-C...set sessionTimeout,maxRetries,retryIntervalMillis - zkc.connect(); - } catch (InterruptedException e) { - LOG.error(e); - } - } - - public synchronized List<String> getChildren(String znode) throws IOException { - List<String> s = null; - - try { - openZk(); - s = zkc.getChildren(znode,null); - } catch (InterruptedException e) { - LOG.error(e); - } catch (KeeperException e) { - LOG.error(e); - } catch (NullPointerException e) { - LOG.error(e); - } - - return s; - } - - public synchronized List<String> getMaster() throws IOException { - return getChildren(parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER); - } - public synchronized List<String> getRunning() throws IOException { - return getChildren(parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING); - } - public synchronized List<String> getRegistered() throws IOException { - return getChildren(parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_REGISTERED); - } - - Configuration getConfiguration() { - return conf; - } - - /** - * Helper method to determine if server should - * only respond to GET HTTP method requests. - * @return boolean for server read-only state - */ - boolean isReadOnly() { - return getConfiguration().getBoolean("dcs.rest.readonly", false); - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/ResourceBase.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/ResourceBase.java b/dcs/src/main/java/org/trafodion/dcs/rest/ResourceBase.java deleted file mode 100644 index 00d64eb..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/ResourceBase.java +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -package org.trafodion.dcs.rest; - -import java.io.IOException; - -public class ResourceBase implements RestConstants { - - RESTServlet servlet; - - public ResourceBase() throws IOException { - servlet = RESTServlet.getInstance(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/ResourceConfig.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/ResourceConfig.java b/dcs/src/main/java/org/trafodion/dcs/rest/ResourceConfig.java deleted file mode 100644 index 32a211e..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/ResourceConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -package org.trafodion.dcs.rest; - -import com.sun.jersey.api.core.PackagesResourceConfig; - -public class ResourceConfig extends PackagesResourceConfig { - public ResourceConfig() { - super("org.trafodion.dcs.rest"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/RestConstants.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/RestConstants.java b/dcs/src/main/java/org/trafodion/dcs/rest/RestConstants.java deleted file mode 100644 index 1eee4df..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/RestConstants.java +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -/** - * Copyright 2007 The Apache Software Foundation - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.trafodion.dcs.rest; - -/** - * Common constants for org.trafodion.dcs.rest - */ -public interface RestConstants { - public static final String VERSION_STRING = "0.0.2"; - - public static final int DEFAULT_MAX_AGE = 60 * 60 * 4; // 4 hours - - public static final int DEFAULT_LISTEN_PORT = 8080; - - public static final String MIMETYPE_TEXT = "text/plain"; - public static final String MIMETYPE_HTML = "text/html"; - public static final String MIMETYPE_XML = "text/xml"; - public static final String MIMETYPE_BINARY = "application/octet-stream"; - public static final String MIMETYPE_PROTOBUF = "application/x-protobuf"; - public static final String MIMETYPE_PROTOBUF_IETF = "application/protobuf"; - public static final String MIMETYPE_JSON = "application/json"; - - public static final String CRLF = "\r\n"; -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/RootResource.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/RootResource.java b/dcs/src/main/java/org/trafodion/dcs/rest/RootResource.java deleted file mode 100644 index eb9d0dc..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/RootResource.java +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -package org.trafodion.dcs.rest; - -import java.io.*; -import java.util.*; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.CacheControl; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import javax.ws.rs.core.Response.ResponseBuilder; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.trafodion.dcs.Constants; -import org.trafodion.dcs.util.Bytes; -import org.trafodion.dcs.rest.RestConstants; - -@Path("/") -public class RootResource extends ResourceBase { - private static final Log LOG = LogFactory.getLog(RootResource.class); - - static CacheControl cacheControl; - static { - cacheControl = new CacheControl(); - cacheControl.setNoCache(true); - cacheControl.setNoTransform(false); - } - - public RootResource() throws IOException { - super(); - } - - @GET - @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON}) - public Response get(final @Context UriInfo uriInfo) { - if (LOG.isDebugEnabled()) { - LOG.debug("GET " + uriInfo.getAbsolutePath()); - } - - try { - return new WorkloadResource().get(uriInfo); - } catch (IOException e) { - return Response.status(Response.Status.SERVICE_UNAVAILABLE) - .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF) - .build(); - } - - } - - @Path("/v1/servers") - public ServerResource getServerResource() throws IOException { - //To test: - //curl -v -X GET -H "Accept: application/json" http://<DcsMaster IP address>:8080/v1/servers - // - return new ServerResource(); - } - - @Path("/v1/workloads") - public WorkloadResource getWorkloadResource() throws IOException { - //To test: - //curl -v -X GET -H "Accept: application/json" http://<DcsMaster IP address>:8080/v1/workloads - // - return new WorkloadResource(); - } - - @Path("/v1/version") - public VersionResource getVersionResource() throws IOException { - //To test: - //curl -v -X GET -H "Accept: application/json" http://<DcsMaster IP address>:8080/v1/version - // - return new VersionResource(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/ServerConnector.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/ServerConnector.java b/dcs/src/main/java/org/trafodion/dcs/rest/ServerConnector.java deleted file mode 100644 index 35cafd9..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/ServerConnector.java +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -package org.trafodion.dcs.rest; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.StringTokenizer; -import java.util.List; -import java.util.Iterator; -import java.util.HashMap; -import java.util.Map; - -//import org.apache.avro.ipc.NettyTransceiver; -//import org.apache.avro.ipc.Transceiver; -//import org.apache.avro.ipc.specific.SpecificRequestor; -//import org.apache.avro.AvroRemoteException; - -import org.trafodion.dcs.Constants; -import org.trafodion.dcs.rest.RestConstants; -import org.trafodion.dcs.zookeeper.ZkClient; - -import org.apache.zookeeper.KeeperException; -import org.apache.zookeeper.data.Stat; -import org.apache.zookeeper.ZooDefs; - -import org.apache.hadoop.conf.Configuration; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -public class ServerConnector { - private static final Log LOG = LogFactory.getLog(ServerConnector.class); -// private Transceiver transceiver; -// private Workload client; -// private WorkloadListRequest request; -/* - public ServerConnector(String ipAddr,int port) throws IOException { - try { - transceiver = new NettyTransceiver(new InetSocketAddress(ipAddr,port)); - client = SpecificRequestor.getClient(Workload.class, transceiver); -// request = WorkloadListRequest.newBuilder().build(); - - } catch (AvroRemoteException e) { - LOG.error(e); - } - } - - public WorkloadListResponse getWorkloadListResponse() { - WorkloadListResponse response = null; - try { - response = client.list(request); - } catch (AvroRemoteException e) { - LOG.error(e); - } - return response; - } -*/ -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/ServerResource.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/ServerResource.java b/dcs/src/main/java/org/trafodion/dcs/rest/ServerResource.java deleted file mode 100644 index 5a39050..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/ServerResource.java +++ /dev/null @@ -1,158 +0,0 @@ -/********************************************************************** -* @@@ START COPYRIGHT @@@ -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -* @@@ END COPYRIGHT @@@ -**********************************************************************/ - -package org.trafodion.dcs.rest; - -import java.io.*; -import java.util.*; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.CacheControl; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import javax.ws.rs.core.Response.ResponseBuilder; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.apache.zookeeper.ZooDefs; -import org.apache.zookeeper.data.Stat; - -import org.trafodion.dcs.Constants; -import org.trafodion.dcs.util.Bytes; -import org.trafodion.dcs.zookeeper.ZkClient; -import org.trafodion.dcs.rest.RestConstants; -import org.trafodion.dcs.rest.model.ServerModel; - -public class ServerResource extends ResourceBase { - private static final Log LOG = - LogFactory.getLog(ServerResource.class); - - static CacheControl cacheControl; - static { - cacheControl = new CacheControl(); - cacheControl.setNoCache(true); - cacheControl.setNoTransform(false); - } - - /** -* @@@ START COPYRIGHT @@@ - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -* @@@ END COPYRIGHT @@@ - */ - public ServerResource() throws IOException { - super(); - } - - @GET - @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON}) - public Response get(final @Context UriInfo uriInfo) { - if (LOG.isDebugEnabled()) { - LOG.debug("GET " + uriInfo.getAbsolutePath()); - } - - try { - List<String> master = servlet.getMaster(); - List<String> running = servlet.getRunning(); - List<String> registered = servlet.getRegistered(); - - ZkClient zkc = servlet.getZk(); - Stat stat = null; - - ServerModel model = new ServerModel(); - - String data = null; - - if(master != null){ - for(String znode: master) { - data = null; - try { - data = Bytes.toString(zkc.getData(servlet.getParentZnode() + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER + "/" + znode, false, stat)); - } catch (Exception e) { - LOG.error(e); - } - - ServerModel.DcsMaster dcsMaster = model.addDcsMaster(znode,data); - - if(running != null){ - Collections.sort(running); - data = null; - for(String znodeRun: running) { - try { - data = Bytes.toString(zkc.getData(servlet.getParentZnode() + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING + "/" + znodeRun, false, stat)); - } catch (Exception e) { - LOG.error(e); - } - - ServerModel.DcsServer dcsServer = dcsMaster.addDcsServer(znodeRun,data); - - if(registered != null){ - Collections.sort(registered); - data = null; - for(String znodeReg: registered) { - try { - data = Bytes.toString(zkc.getData(servlet.getParentZnode() + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_REGISTERED + "/" + znodeReg, false, stat)); - } catch (Exception e) { - LOG.error(e); - } - - dcsServer.addTrafodionServer(znodeReg,data); - } - } - } - } - } - } - - ResponseBuilder response = Response.ok(model); - response.cacheControl(cacheControl); - return response.build(); - } catch (IOException e) { - return Response.status(Response.Status.SERVICE_UNAVAILABLE) - .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF) - .build(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/VersionResource.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/VersionResource.java b/dcs/src/main/java/org/trafodion/dcs/rest/VersionResource.java deleted file mode 100644 index caa7985..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/VersionResource.java +++ /dev/null @@ -1,122 +0,0 @@ -/********************************************************************** -* @@@ START COPYRIGHT @@@ -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -* @@@ END COPYRIGHT @@@ -**********************************************************************/ - -package org.trafodion.dcs.rest; - -import java.io.IOException; - -import javax.servlet.ServletContext; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.CacheControl; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import javax.ws.rs.core.Response.ResponseBuilder; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.trafodion.dcs.rest.model.VersionModel; - -/** -* @@@ START COPYRIGHT @@@ - -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. - -* @@@ END COPYRIGHT @@@ - */ -public class VersionResource extends ResourceBase { - - private static final Log LOG = LogFactory.getLog(VersionResource.class); - - static CacheControl cacheControl; - static { - cacheControl = new CacheControl(); - cacheControl.setNoCache(true); - cacheControl.setNoTransform(false); - } - - /** - * Constructor - * @throws IOException - */ - public VersionResource() throws IOException { - super(); - } - - /** - * Build a response for a version request. - * @param context servlet context - * @param uriInfo (JAX-RS context variable) request URL - * @return a response for a version request - */ - - @GET - @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON}) - public Response get(final @Context ServletContext context, - final @Context UriInfo uriInfo) { - if (LOG.isDebugEnabled()) { - LOG.debug("GET " + uriInfo.getAbsolutePath()); - } - //servlet.getMetrics().incrementRequests(1); - ResponseBuilder response = Response.ok(new VersionModel(context)); - response.cacheControl(cacheControl); - //servlet.getMetrics().incrementSucessfulGetRequests(1); - return response.build(); - } - - /** - * Dispatch to StorageClusterVersionResource - */ -/* - @Path("cluster") - public StorageClusterVersionResource getClusterVersionResource() - throws IOException { - return new StorageClusterVersionResource(); - } -*/ - /** - * Dispatch <tt>/version/rest</tt> to self. - */ - @Path("rest") - public VersionResource getVersionResource() { - return this; - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/WorkloadResource.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/WorkloadResource.java b/dcs/src/main/java/org/trafodion/dcs/rest/WorkloadResource.java deleted file mode 100644 index 6a17110..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/WorkloadResource.java +++ /dev/null @@ -1,140 +0,0 @@ -/********************************************************************** -* @@@ START COPYRIGHT @@@ -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -* @@@ END COPYRIGHT @@@ -**********************************************************************/ -package org.trafodion.dcs.rest; - -import java.io.*; -import java.util.*; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.CacheControl; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; -import javax.ws.rs.core.Response.ResponseBuilder; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.trafodion.dcs.Constants; -import org.trafodion.dcs.util.Bytes; -import org.trafodion.dcs.script.ScriptManager; -import org.trafodion.dcs.script.ScriptContext; -import org.trafodion.dcs.rest.model.WorkloadListModel; -import org.trafodion.dcs.rest.model.WorkloadModel; - -import org.codehaus.jettison.json.JSONArray; -import org.codehaus.jettison.json.JSONException; -import org.codehaus.jettison.json.JSONObject; - -public class WorkloadResource extends ResourceBase { - private static final Log LOG = - LogFactory.getLog(WorkloadResource.class); - - static CacheControl cacheControl; - static { - cacheControl = new CacheControl(); - cacheControl.setNoCache(true); - cacheControl.setNoTransform(false); - } - - /** -* @@@ START COPYRIGHT @@@ - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - -* @@@ END COPYRIGHT @@@ - */ - public WorkloadResource() throws IOException { - super(); - - } - - @GET - @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON}) - public Response get(final @Context UriInfo uriInfo) { - if (LOG.isDebugEnabled()) { - LOG.debug("GET " + uriInfo.getAbsolutePath()); - } - - try { -// ScriptContext scriptContext = new ScriptContext(); -// scriptContext.setScriptName(Constants.JDBCT2UTIL_SCRIPT_NAME); -// scriptContext.setCommand(Constants.TRAFODION_REPOS_METRIC_SESSION_TABLE); - - try { -// ScriptManager.getInstance().runScript(scriptContext);//This will block while script is running - } catch (Exception e) { - e.printStackTrace(); - throw new IOException(e); - } - -// StringBuilder sb = new StringBuilder(); -// sb.append("exit code [" + scriptContext.getExitCode() + "]"); -// if(! scriptContext.getStdOut().toString().isEmpty()) -// sb.append(", stdout [" + scriptContext.getStdOut().toString() + "]"); -// if(! scriptContext.getStdErr().toString().isEmpty()) -// sb.append(", stderr [" + scriptContext.getStdErr().toString() + "]"); -// LOG.info(sb.toString()); - - JSONArray workloadList = null; - -// try { -// if(scriptContext.getExitCode() == 0 && (! scriptContext.getStdOut().toString().isEmpty())) { -// workloadList = new JSONArray(scriptContext.getStdOut().toString()); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// LOG.error(e.getMessage()); -// throw new IOException(e); -// } - - ResponseBuilder response = Response.ok(workloadList); - response.cacheControl(cacheControl); - return response.build(); - } catch (IOException e) { - return Response.status(Response.Status.SERVICE_UNAVAILABLE) - .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF) - .build(); - } - } - -} \ No newline at end of file
