-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature][dingo-executor] Add back up update resolve lock safe point (#…
- Loading branch information
1 parent
3f84fcf
commit 8b5e9e2
Showing
23 changed files
with
1,150 additions
and
383 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
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
70 changes: 70 additions & 0 deletions
70
dingo-calcite/src/main/java/io/dingodb/calcite/executor/AdminBackUpTimePointExecutor.java
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,70 @@ | ||
/* | ||
* Copyright 2021 DataCanvas | ||
* | ||
* 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 io.dingodb.calcite.executor; | ||
|
||
import io.dingodb.common.mysql.util.DataTimeUtils; | ||
import io.dingodb.common.util.Pair; | ||
import io.dingodb.transaction.api.GcService; | ||
import io.dingodb.tso.TsoService; | ||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
public class AdminBackUpTimePointExecutor extends QueryExecutor { | ||
|
||
public static final List<String> COLUMNS = Arrays.asList( | ||
"STATUS", "SAFE_POINT" | ||
); | ||
public static final int INDEX_STATUS = 0; | ||
|
||
public static final int INDEX_TSO = 1; | ||
|
||
@Getter | ||
private final String timeStr; | ||
|
||
public AdminBackUpTimePointExecutor(String timeStr) { | ||
this.timeStr = timeStr; | ||
} | ||
|
||
@Override | ||
public Iterator getIterator() { | ||
long time = DataTimeUtils.parseDate(timeStr); | ||
long point = TsoService.getDefault().tso(time); | ||
long latestTso = TsoService.getDefault().tso(); | ||
if (point > latestTso) { | ||
throw new RuntimeException("The specified time:"+ timeStr +" is greater than the " + | ||
"current latest tso:" + latestTso); | ||
} | ||
Pair<String, Long> stringLongPair = GcService.getDefault().startBackUpSafeByPoint(point, latestTso); | ||
List<Object[]> gcColumns = new ArrayList<>(); | ||
Object[] objects = new Object[COLUMNS.size()]; | ||
objects[INDEX_STATUS] = stringLongPair.getKey(); | ||
objects[INDEX_TSO] = stringLongPair.getValue(); | ||
gcColumns.add(objects); | ||
return gcColumns.iterator(); | ||
} | ||
|
||
@Override | ||
public List<String> columns() { | ||
return COLUMNS; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
dingo-calcite/src/main/java/io/dingodb/calcite/executor/AdminBackUpTsoPointExecutor.java
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,67 @@ | ||
/* | ||
* Copyright 2021 DataCanvas | ||
* | ||
* 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 io.dingodb.calcite.executor; | ||
|
||
import io.dingodb.common.util.Pair; | ||
import io.dingodb.transaction.api.GcService; | ||
import io.dingodb.tso.TsoService; | ||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
public class AdminBackUpTsoPointExecutor extends QueryExecutor { | ||
|
||
public static final List<String> COLUMNS = Arrays.asList( | ||
"STATUS", "SAFE_POINT" | ||
); | ||
public static final int INDEX_STATUS = 0; | ||
|
||
public static final int INDEX_TSO = 1; | ||
|
||
@Getter | ||
private final long point; | ||
|
||
public AdminBackUpTsoPointExecutor(long point) { | ||
this.point = point; | ||
} | ||
|
||
@Override | ||
public Iterator getIterator() { | ||
long latestTso = TsoService.getDefault().tso(); | ||
if (point > latestTso) { | ||
throw new RuntimeException("The specified tso:"+ point +" is greater than the " + | ||
"current latest tso:" + latestTso); | ||
} | ||
Pair<String, Long> stringLongPair = GcService.getDefault().startBackUpSafeByPoint(point, latestTso); | ||
List<Object[]> gcColumns = new ArrayList<>(); | ||
Object[] objects = new Object[COLUMNS.size()]; | ||
objects[INDEX_STATUS] = stringLongPair.getKey(); | ||
objects[INDEX_TSO] = stringLongPair.getValue(); | ||
gcColumns.add(objects); | ||
return gcColumns.iterator(); | ||
} | ||
|
||
@Override | ||
public List<String> columns() { | ||
return COLUMNS; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
dingo-calcite/src/main/java/io/dingodb/calcite/executor/AdminStartGcExecutor.java
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,56 @@ | ||
/* | ||
* Copyright 2021 DataCanvas | ||
* | ||
* 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 io.dingodb.calcite.executor; | ||
|
||
import io.dingodb.common.util.Pair; | ||
import io.dingodb.transaction.api.GcService; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
public class AdminStartGcExecutor extends QueryExecutor { | ||
|
||
public static final List<String> COLUMNS = Arrays.asList( | ||
"STATUS", "SAFE_POINT" | ||
); | ||
public static final int INDEX_STATUS = 0; | ||
|
||
public static final int INDEX_TSO = 1; | ||
|
||
public AdminStartGcExecutor() { | ||
} | ||
|
||
@Override | ||
public Iterator getIterator() { | ||
Pair<String, Long> stringLongPair = GcService.getDefault().startSafePointUpdate(); | ||
List<Object[]> gcColumns = new ArrayList<>(); | ||
Object[] objects = new Object[COLUMNS.size()]; | ||
objects[INDEX_STATUS] = stringLongPair.getKey(); | ||
objects[INDEX_TSO] = stringLongPair.getValue(); | ||
gcColumns.add(objects); | ||
return gcColumns.iterator(); | ||
} | ||
|
||
@Override | ||
public List<String> columns() { | ||
return COLUMNS; | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
dingo-calcite/src/main/java/io/dingodb/calcite/grammar/dql/SqlBackUpTimePoint.java
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,44 @@ | ||
/* | ||
* Copyright 2021 DataCanvas | ||
* | ||
* 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 io.dingodb.calcite.grammar.dql; | ||
|
||
import io.dingodb.calcite.grammar.ddl.SqlAdmin; | ||
import org.apache.calcite.sql.SqlKind; | ||
import org.apache.calcite.sql.SqlOperator; | ||
import org.apache.calcite.sql.SqlSpecialOperator; | ||
import org.apache.calcite.sql.SqlWriter; | ||
import org.apache.calcite.sql.parser.SqlParserPos; | ||
|
||
|
||
public class SqlBackUpTimePoint extends SqlAdmin { | ||
public String timeStr; | ||
|
||
private static final SqlOperator OPERATOR = | ||
new SqlSpecialOperator("ADMIN BACK_UP_TIME_POINT", SqlKind.SELECT); | ||
|
||
public SqlBackUpTimePoint(SqlParserPos pos, String timeStr) { | ||
super(OPERATOR, pos); | ||
if (timeStr != null) { | ||
this.timeStr = timeStr; | ||
} | ||
} | ||
|
||
@Override | ||
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { | ||
writer.keyword("ADMIN BACK_UP_TIME_POINT"); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
dingo-calcite/src/main/java/io/dingodb/calcite/grammar/dql/SqlBackUpTsoPoint.java
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,45 @@ | ||
/* | ||
* Copyright 2021 DataCanvas | ||
* | ||
* 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 io.dingodb.calcite.grammar.dql; | ||
|
||
import io.dingodb.calcite.grammar.ddl.SqlAdmin; | ||
import org.apache.calcite.sql.SqlKind; | ||
import org.apache.calcite.sql.SqlOperator; | ||
import org.apache.calcite.sql.SqlSpecialOperator; | ||
import org.apache.calcite.sql.SqlWriter; | ||
import org.apache.calcite.sql.parser.SqlParserPos; | ||
|
||
import java.math.BigInteger; | ||
|
||
public class SqlBackUpTsoPoint extends SqlAdmin { | ||
public long point; | ||
|
||
private static final SqlOperator OPERATOR = | ||
new SqlSpecialOperator("ADMIN BACK_UP_TSO_POINT", SqlKind.SELECT); | ||
|
||
public SqlBackUpTsoPoint(SqlParserPos pos, BigInteger point) { | ||
super(OPERATOR, pos); | ||
if (point != null) { | ||
this.point = point.longValue(); | ||
} | ||
} | ||
|
||
@Override | ||
public void unparse(SqlWriter writer, int leftPrec, int rightPrec) { | ||
writer.keyword("ADMIN BACK_UP_TSO_POINT"); | ||
} | ||
} |
Oops, something went wrong.