-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from pingcap-inc/sprint/20211231/sprint6
Sprint/20211231/sprint6
- Loading branch information
Showing
432 changed files
with
61,996 additions
and
41,821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ prepare: | |
@if [ -f "$(CURDIR)/$(PROTOC_PKG)" ]; then unzip -o $(PROTOC_PKG) -d $(GOPATH) bin/protoc; fi | ||
@if [ -f "$(CURDIR)/$(PROTOC_PKG)" ]; then unzip -o $(PROTOC_PKG) -d $(GOPATH) 'include/*'; fi | ||
@if [ -f "$(CURDIR)/$(PROTOC_PKG)" ]; then rm -rf $(PROTOC_PKG); fi | ||
@cp -r micro-cluster/cluster/management/handler/template ./ | ||
|
||
# generate protobuf files | ||
proto: | ||
|
@@ -200,8 +201,9 @@ clean: | |
@if [ -f ${TIEM_BINARY_DIR}/vfsgendev ] ; then rm ${TIEM_BINARY_DIR}/vfsgendev; fi | ||
@if [ -f ${TIEM_BINARY_DIR}/golangci-lint ] ; then rm ${TIEM_BINARY_DIR}/golangci-lint; fi | ||
@if [ -f ${TIEM_BINARY_DIR}/errdoc-gen ] ; then rm ${TIEM_BINARY_DIR}/errdoc-gen; fi | ||
@if [ -f ${GENERATE_TARGET_DIR}/cluster ] ; then rm -rf ${GENERATE_TARGET_DIR}/cluster; fi | ||
@if [ -f ${GENERATE_TARGET_DIR}/metadb ] ; then rm -rf ${GENERATE_TARGET_DIR}/metadb; fi | ||
@if [ -d ${GENERATE_TARGET_DIR}/cluster ] ; then rm -rf ${GENERATE_TARGET_DIR}/cluster; fi | ||
@if [ -d ${GENERATE_TARGET_DIR}/metadb ] ; then rm -rf ${GENERATE_TARGET_DIR}/metadb; fi | ||
@if [ -d ${CURDIR}/test ] ; then rm -rf ${CURDIR}/test; fi | ||
|
||
help: | ||
@echo "make build, build binary for all servers" | ||
|
@@ -271,7 +273,26 @@ add_test_file: | |
build_helper/add_test_file.sh | ||
|
||
mock: | ||
go get github.com/golang/mock/mockgen | ||
$(GO) install github.com/golang/mock/mockgen | ||
mockgen -destination ./test/mocksecondparty/mock_second_party_manager.go -package mocksecondparty -source ./library/secondparty/second_party_manager.go | ||
mockgen -destination ./test/mockdb/mock_db.pb.micro.go -package mockdb -source ./library/client/metadb/dbpb/db.pb.micro.go | ||
mockgen -destination ./test/mockcluster/mock_cluster.pb.micro.go -package mockcluster -source ./library/client/cluster/clusterpb/cluster.pb.micro.go | ||
|
||
mockgen -destination ./test/mockmodels/mockmanagement/mock_management_interface.go -package mockmanagement -source ./models/cluster/management/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mockworkflow/mock_workflow_interface.go -package mockworkflow -source ./models/workflow/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mockbr/mock_br_interface.go -package mockbr -source ./models/cluster/backuprestore/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mockimportexport/mock_importexport_interface.go -package mockimportexport -source ./models/datatransfer/importexport/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mockresource/mock_resource_interface.go -package mockresource -source ./models/resource/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mockconfig/mock_config_interface.go -package mockconfig -source ./models/platform/config/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mocksecondparty/mock_secondparty_interface.go -package mocksecondparty -source ./models/workflow/secondparty/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mockparametergroup/mock_parametergroup_interface.go -package mockparametergroup -source ./models/parametergroup/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mockclusterparameter/mock_clusterparameter_interface.go -package mockclusterparameter -source ./models/cluster/parameter/readerwriter.go | ||
mockgen -destination ./test/mockmodels/mockclustermanagement/mock_cluster_management_interface.go -package mockclustermanagement -source ./models/cluster/management/readerwriter.go | ||
|
||
mockgen -destination ./test/mockworkflow/mock_workflow.go -package mock_workflow_service -source ./workflow/workflow.go | ||
mockgen -destination ./test/mockbr/mock_br.go -package mock_br_service -source ./micro-cluster/cluster/backuprestore/service.go | ||
mockgen -destination ./test/mocksecondparty_v2/mock_secondparty.go -package mock_secondparty -source ./library/secondparty/second_party_manager_v2.go | ||
|
||
swag: | ||
$(GO) install github.com/swaggo/swag/cmd/[email protected] | ||
swag init -g micro-api/main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2021 PingCAP, Inc. * | ||
* Licensed 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 constants | ||
|
||
import ( | ||
"github.com/pingcap-inc/tiem/common/errors" | ||
) | ||
|
||
type ChangeFeedStatus string | ||
|
||
const ( | ||
Initial ChangeFeedStatus = "Initial" | ||
Normal ChangeFeedStatus = "Normal" | ||
Stopped ChangeFeedStatus = "Stopped" | ||
Finished ChangeFeedStatus = "Finished" | ||
Error ChangeFeedStatus = "Error" | ||
Failed ChangeFeedStatus = "Failed" | ||
Unknown ChangeFeedStatus = "Unknown" | ||
) | ||
|
||
func (s ChangeFeedStatus) IsFinal() bool { | ||
return Finished == s || Failed == s | ||
} | ||
|
||
func (s ChangeFeedStatus) ToString() string { | ||
return string(s) | ||
} | ||
|
||
func IsValidStatus(s string) bool { | ||
return Initial.ToString() == s || | ||
Normal.ToString() == s || | ||
Stopped.ToString() == s || | ||
Finished.ToString() == s || | ||
Error.ToString() == s || | ||
Failed.ToString() == s | ||
} | ||
|
||
func ConvertStatus(s string) (status ChangeFeedStatus, err error) { | ||
if IsValidStatus(s) { | ||
return ChangeFeedStatus(s), nil | ||
} else { | ||
return Unknown, errors.NewError(errors.TIEM_PARAMETER_INVALID, "unexpected change feed status") | ||
} | ||
} | ||
|
||
type DownstreamType string | ||
|
||
const ( | ||
DownstreamTypeTiDB DownstreamType = "tidb" | ||
DownstreamTypeKafka DownstreamType = "kafka" | ||
DownstreamTypeMysql DownstreamType = "mysql" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2021 PingCAP, Inc. * | ||
* Licensed 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. * | ||
******************************************************************************/ | ||
|
||
/******************************************************************************* | ||
* @File: cluster.go | ||
* @Description: | ||
* @Author: [email protected] | ||
* @Version: 1.0.0 | ||
* @Date: 2021/12/4 | ||
*******************************************************************************/ | ||
|
||
package constants | ||
|
||
type ClusterRunningStatus string | ||
|
||
//Definition of cluster running status information | ||
const ( | ||
ClusterInitializing ClusterRunningStatus = "Initializing" | ||
ClusterStopped ClusterRunningStatus = "Stopped" | ||
ClusterRunning ClusterRunningStatus = "Running" | ||
ClusterRecovering ClusterRunningStatus = "Recovering" | ||
ClusterFailure ClusterRunningStatus = "Failure" | ||
) | ||
|
||
type ClusterMaintenanceStatus string | ||
|
||
// Definition cluster maintenance status information | ||
const ( | ||
ClusterMaintenanceCreating ClusterMaintenanceStatus = "Creating" | ||
ClusterMaintenanceCloning ClusterMaintenanceStatus = "Cloning" | ||
ClusterMaintenanceDeleting ClusterMaintenanceStatus = "Deleting" | ||
ClusterMaintenanceStopping ClusterMaintenanceStatus = "Stopping" | ||
ClusterMaintenanceRestarting ClusterMaintenanceStatus = "Restarting" | ||
ClusterMaintenanceBackUp ClusterMaintenanceStatus = "BackUp" | ||
ClusterMaintenanceRestore ClusterMaintenanceStatus = "Restore" | ||
ClusterMaintenanceScaleIn ClusterMaintenanceStatus = "ScaleIn" | ||
ClusterMaintenanceScaleOut ClusterMaintenanceStatus = "ScaleOut" | ||
ClusterMaintenanceUpgrading ClusterMaintenanceStatus = "Upgrading" | ||
ClusterMaintenanceSwitching ClusterMaintenanceStatus = "Switching" | ||
ClusterMaintenanceModifyParameterAndRestarting ClusterMaintenanceStatus = "ModifyParameterRestarting" | ||
ClusterMaintenanceTakeover ClusterMaintenanceStatus = "Takeover" | ||
ClusterMaintenanceNone ClusterMaintenanceStatus = "" | ||
) | ||
|
||
const ( | ||
FlowCreateCluster = "CreateCluster" | ||
FlowDeleteCluster = "DeleteCluster" | ||
FlowBackupCluster = "BackupCluster" | ||
FlowRestoreNewCluster = "RestoreNewCluster" | ||
FlowRestoreExistCluster = "RestoreExistCluster" | ||
FlowModifyParameters = "ModifyParameters" | ||
FlowExportData = "ExportData" | ||
FlowImportData = "ImportData" | ||
FlowRestartCluster = "RestartCluster" | ||
FlowStopCluster = "StopCluster" | ||
FlowTakeoverCluster = "BuildForTakeover" | ||
FlowBuildLogConfig = "BuildLogConfig" | ||
FlowScaleOutCluster = "ScaleOutCluster" | ||
FlowScaleInCluster = "ScaleInCluster" | ||
FlowCloneCluster = "CloneCluster" | ||
) | ||
|
||
type ClusterInstanceRunningStatus string | ||
|
||
//Definition of cluster instance running status information | ||
const ( | ||
ClusterInstanceInitializing ClusterInstanceRunningStatus = "Initializing" | ||
ClusterInstanceStopped ClusterInstanceRunningStatus = "Stopped" | ||
ClusterInstanceRunning ClusterInstanceRunningStatus = "Running" | ||
ClusterInstanceRecovering ClusterInstanceRunningStatus = "Recovering" | ||
ClusterInstanceFailure ClusterInstanceRunningStatus = "Failure" | ||
) | ||
|
||
type ClusterInstanceMaintenanceStatus string | ||
|
||
// Definition cluster instance maintenance status information | ||
const ( | ||
ClusterInstanceMaintenanceCreating ClusterInstanceMaintenanceStatus = "Creating" | ||
ClusterInstanceMaintenanceDeleting ClusterInstanceMaintenanceStatus = "Deleting" | ||
ClusterInstanceMaintenanceStopping ClusterInstanceMaintenanceStatus = "Stopping" | ||
ClusterInstanceMaintenanceRestarting ClusterInstanceMaintenanceStatus = "Restarting" | ||
ClusterInstanceMaintenanceUpgrading ClusterInstanceMaintenanceStatus = "Upgrading" | ||
ClusterInstanceMaintenanceModifyParameterAndRestarting ClusterInstanceMaintenanceStatus = "ModifyParameterRestarting" | ||
) | ||
|
||
type ClusterBackupStatus string | ||
|
||
//Definition of cluster backup status information | ||
const ( | ||
ClusterBackupInitializing ClusterBackupStatus = "Initializing" | ||
ClusterBackupProcessing ClusterBackupStatus = "Processing" | ||
ClusterBackupFinished ClusterBackupStatus = "Finished" | ||
ClusterBackupFailed ClusterBackupStatus = "Failed" | ||
) | ||
|
||
type ClusterRelationType string | ||
|
||
//Constants for the relationships between clusters | ||
const ( | ||
ClusterRelationSlaveTo ClusterRelationType = "SlaveTo" | ||
ClusterRelationStandBy ClusterRelationType = "StandBy" | ||
ClusterRelationCloneFrom ClusterRelationType = "CloneFrom" | ||
ClusterRelationRecoverFrom ClusterRelationType = "RecoverFrom" | ||
) | ||
|
||
type ClusterCloneStrategy string | ||
|
||
// Definition cluster clone strategy | ||
const ( | ||
ClusterTopologyClone ClusterCloneStrategy = "TopologyClone" | ||
SnapShotClone ClusterCloneStrategy = "Snapshot" | ||
TiCDCSyncClone ClusterCloneStrategy = "TiCDCSync" | ||
) | ||
|
||
type BackupType string | ||
type BackupMethod string | ||
|
||
//Definition backup data method and type | ||
const ( | ||
BackupTypeFull BackupType = "full" | ||
BackupTypeIncrement BackupType = "incr" | ||
BackupMethodLogic BackupMethod = "logical" | ||
BackupMethodPhysics BackupMethod = "physical" | ||
) | ||
|
||
type BackupMode string | ||
|
||
//Definition backup data mode | ||
const ( | ||
BackupModeAuto BackupMode = "auto" | ||
BackupModeManual BackupMode = "manual" | ||
) | ||
|
||
type StorageType string | ||
|
||
//Definition backup data storage type | ||
const ( | ||
StorageTypeLocal StorageType = "local" | ||
StorageTypeS3 StorageType = "s3" | ||
StorageTypeNFS StorageType = "nfs" | ||
) | ||
|
||
const ( | ||
DefaultBackupStoragePath string = "nfs/em/backup" | ||
DefaultBackupS3AccessKey string = "minioadmin" | ||
DefaultBackupS3SecretAccessKey string = "minioadmin" | ||
DefaultBackupS3Endpoint string = "http://minio.pingcap.net:9000" | ||
) |
Oops, something went wrong.