Skip to content

Commit be3bd78

Browse files
committed
Refactor SyncStatusCode and ErrorDetails into seperate classes, introduce MaturtityLevel in xtable-api
1 parent 563a7fa commit be3bd78

File tree

20 files changed

+556
-40
lines changed

20 files changed

+556
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable;
20+
21+
public enum MaturityLevel {
22+
/**
23+
* New APIs start out in this state. Although enough thought will be given to avoid breaking
24+
* changes to the API in the future, sometimes it might need to change based on feedback.
25+
*/
26+
EVOLVING,
27+
/**
28+
* Enough applications/users have picked up the API and we deem it stable. We will strive to never
29+
* break the stability of such APIs within a given major version release.
30+
*/
31+
STABLE,
32+
/**
33+
* New things are born, old things fade away. This holds true for APIs also. Once an API has been
34+
* marked as deprecated, new APIs replacing them (if need be) would be in stable state for users
35+
* to migrate to.
36+
*/
37+
DEPRECATED
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable;
20+
21+
import java.lang.annotation.Documented;
22+
import java.lang.annotation.ElementType;
23+
import java.lang.annotation.Inherited;
24+
import java.lang.annotation.Retention;
25+
import java.lang.annotation.RetentionPolicy;
26+
import java.lang.annotation.Target;
27+
28+
/** Annotates a public class, used in user code. */
29+
@Inherited
30+
@Documented
31+
@Target(ElementType.TYPE)
32+
@Retention(RetentionPolicy.CLASS)
33+
public @interface PublicAPIClass {
34+
MaturityLevel maturity();
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable;
20+
21+
import java.lang.annotation.Documented;
22+
import java.lang.annotation.ElementType;
23+
import java.lang.annotation.Inherited;
24+
import java.lang.annotation.Retention;
25+
import java.lang.annotation.RetentionPolicy;
26+
import java.lang.annotation.Target;
27+
28+
/** Annotates a public method, used in user code. */
29+
@Inherited
30+
@Documented
31+
@Target(ElementType.METHOD)
32+
@Retention(RetentionPolicy.CLASS)
33+
public @interface PublicAPIMethod {
34+
MaturityLevel maturity();
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.sync;
20+
21+
import lombok.Builder;
22+
import lombok.Value;
23+
24+
import org.apache.xtable.MaturityLevel;
25+
import org.apache.xtable.PublicAPIClass;
26+
27+
@Value
28+
@Builder
29+
@PublicAPIClass(maturity = MaturityLevel.EVOLVING)
30+
public class ErrorDetails {
31+
// error Message if any
32+
String errorMessage;
33+
// Readable description of the error
34+
String errorDescription;
35+
// Can the client retry for this type of error (Transient error=true, persistent error=false)
36+
boolean canRetryOnFailure;
37+
38+
public static ErrorDetails create(Exception e, String errorDescription) {
39+
if (e == null) {
40+
return null;
41+
}
42+
43+
return ErrorDetails.builder()
44+
.errorMessage(e.getMessage())
45+
.errorDescription(errorDescription)
46+
.canRetryOnFailure(true)
47+
.build();
48+
}
49+
}

xtable-api/src/main/java/org/apache/xtable/model/sync/SyncResult.java

+6-18
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@
2020

2121
import java.time.Duration;
2222
import java.time.Instant;
23+
import java.util.Collections;
2324
import java.util.List;
2425

2526
import lombok.Builder;
2627
import lombok.Value;
2728

29+
import org.apache.xtable.MaturityLevel;
30+
import org.apache.xtable.PublicAPIClass;
31+
2832
/**
2933
* Result of a sync operation
3034
*
3135
* @since 0.1
3236
*/
3337
@Value
3438
@Builder(toBuilder = true)
39+
@PublicAPIClass(maturity = MaturityLevel.EVOLVING)
3540
public class SyncResult {
3641
// Mode used for the sync
3742
SyncMode mode;
@@ -44,13 +49,7 @@ public class SyncResult {
4449
// The Sync Mode recommended for the next sync (Usually filled on an error)
4550
SyncMode recommendedSyncMode;
4651
// The sync status for each catalog.
47-
List<CatalogSyncStatus> catalogSyncStatusList;
48-
49-
public enum SyncStatusCode {
50-
SUCCESS,
51-
ABORTED,
52-
ERROR
53-
}
52+
@Builder.Default List<CatalogSyncStatus> catalogSyncStatusList = Collections.emptyList();
5453

5554
/** Represents the status of a Sync operation. */
5655
@Value
@@ -75,15 +74,4 @@ public static class CatalogSyncStatus {
7574
// errorDetails if any
7675
ErrorDetails errorDetails;
7776
}
78-
79-
@Value
80-
@Builder
81-
public static class ErrorDetails {
82-
// error Message if any
83-
String errorMessage;
84-
// Readable description of the error
85-
String errorDescription;
86-
// Can the client retry for this type of error (Transient error=true, persistent error=false)
87-
boolean canRetryOnFailure;
88-
}
8977
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.xtable.model.sync;
20+
21+
/** Enum representing the status of a synchronization operation. */
22+
public enum SyncStatusCode {
23+
24+
/** Indicates that the sync was successful. */
25+
SUCCESS,
26+
27+
/** Indicates that the sync was aborted before completion. */
28+
ABORTED,
29+
30+
/** Indicates that an error occurred during sync. */
31+
ERROR
32+
}

0 commit comments

Comments
 (0)