You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by se...@apache.org on 2018/01/05 10:38:17 UTC
[incubator-servicecomb-saga] 02/02: SCB-183 unused class removal
This is an automated email from the ASF dual-hosted git repository.
seanyinx pushed a commit to branch SCB-183_callback_cleanup
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git
commit e19f74968ab93fb179c39d01a00175ae2eec6a61
Author: seanyinx <se...@huawei.com>
AuthorDate: Fri Jan 5 17:56:31 2018 +0800
SCB-183 unused class removal
Signed-off-by: seanyinx <se...@huawei.com>
---
.../saga/alpha/core/SelfCleaningOmegaCallback.java | 54 ----------------
.../alpha/core/SelfCleaningOmegaCallbackTest.java | 74 ----------------------
2 files changed, 128 deletions(-)
diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/SelfCleaningOmegaCallback.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/SelfCleaningOmegaCallback.java
deleted file mode 100644
index d7b984d..0000000
--- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/SelfCleaningOmegaCallback.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.apache.servicecomb.saga.alpha.core;
-
-import java.lang.invoke.MethodHandles;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SelfCleaningOmegaCallback implements OmegaCallback {
- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- private final String instanceId;
- private final OmegaCallback underlying;
- private final Map<String, OmegaCallback> callbacks;
-
- SelfCleaningOmegaCallback(String instanceId, OmegaCallback underlying, Map<String, OmegaCallback> callbacks) {
- this.instanceId = instanceId;
- this.underlying = underlying;
- this.callbacks = callbacks;
- }
-
- @Override
- public void compensate(TxEvent event) {
- try {
- underlying.compensate(event);
- } catch (Exception e) {
- callbacks.remove(instanceId);
- log.error("Removed omega callback with instance id [{}] due to connection disruption", instanceId, e);
- throw e;
- }
- }
-
- @Override
- public void disconnect() {
- underlying.disconnect();
- }
-}
diff --git a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/SelfCleaningOmegaCallbackTest.java b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/SelfCleaningOmegaCallbackTest.java
deleted file mode 100644
index d6253a8..0000000
--- a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/SelfCleaningOmegaCallbackTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.apache.servicecomb.saga.alpha.core;
-
-import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing;
-import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.verify;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-public class SelfCleaningOmegaCallbackTest {
- private final TxEvent event = Mockito.mock(TxEvent.class);
- private final String someId = uniquify("someId");
-
- private final Map<String, OmegaCallback> callbacks = new HashMap<>();
- private final OmegaCallback underlying = Mockito.mock(OmegaCallback.class);
- private final SelfCleaningOmegaCallback callback = new SelfCleaningOmegaCallback(someId, underlying, callbacks);
-
- @Before
- public void setUp() throws Exception {
- callbacks.put(someId, callback);
- }
-
- @Test
- public void keepItselfInCallbacksWhenNormal() throws Exception {
- callback.compensate(event);
-
- assertThat(callbacks.get(someId), is(callback));
- }
-
- @Test
- public void removeItselfFromCallbacksOnException() throws Exception {
- doThrow(RuntimeException.class).when(underlying).compensate(any(TxEvent.class));
-
- try {
- callback.compensate(event);
- expectFailing(RuntimeException.class);
- } catch (RuntimeException ignored) {
- }
-
- assertThat(callbacks.isEmpty(), is(true));
- }
-
- @Test
- public void disconnectWithUnderlying() throws Exception {
- callback.disconnect();
-
- verify(underlying).disconnect();
- }
-}
--
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.