Skip to content

Commit 4210c45

Browse files
author
MDH
committed
Fix ehcache reconnect
1 parent 900433f commit 4210c45

27 files changed

+1066
-528
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright Terracotta, Inc.
3+
* Copyright IBM Corp. 2024, 2025
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.ehcache.clustered.client.internal.reconnect;
18+
19+
public class FailedClusterTierException extends RuntimeException {
20+
private static final long serialVersionUID = 4659324574239228097L;
21+
22+
public FailedClusterTierException(String message, Throwable cause) {
23+
super(message, cause);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright Terracotta, Inc.
3+
* Copyright IBM Corp. 2024, 2025
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.ehcache.clustered.client.internal.reconnect;
18+
19+
import org.ehcache.CachePersistenceException;
20+
import org.ehcache.clustered.client.config.Timeouts;
21+
import org.ehcache.clustered.client.internal.service.ClusterTierException;
22+
import org.ehcache.clustered.client.internal.store.ClusterTierClientEntity;
23+
import org.ehcache.clustered.common.internal.ServerStoreConfiguration;
24+
import org.ehcache.clustered.common.internal.exceptions.ClusterException;
25+
import org.ehcache.clustered.common.internal.messages.EhcacheEntityResponse;
26+
import org.ehcache.clustered.common.internal.messages.EhcacheOperationMessage;
27+
import org.ehcache.clustered.common.internal.messages.StateRepositoryOpMessage;
28+
29+
import java.util.concurrent.TimeoutException;
30+
31+
public class FailedReconnectClusterTierClientEntity implements ClusterTierClientEntity {
32+
private final String cacheId;
33+
private final CachePersistenceException failure;
34+
35+
public FailedReconnectClusterTierClientEntity(String cacheId, CachePersistenceException failure) {
36+
this.cacheId = cacheId;
37+
this.failure = failure;
38+
}
39+
40+
public String getCacheId() {
41+
return cacheId;
42+
}
43+
44+
@Override
45+
public Timeouts getTimeouts() {
46+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
47+
}
48+
49+
@Override
50+
public boolean isConnected() {
51+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
52+
}
53+
54+
@Override
55+
public void validate(ServerStoreConfiguration clientStoreConfiguration) throws ClusterTierException, TimeoutException {
56+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
57+
}
58+
59+
@Override
60+
public void invokeAndWaitForSend(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException {
61+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
62+
}
63+
64+
@Override
65+
public void invokeAndWaitForReceive(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException {
66+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
67+
}
68+
69+
@Override
70+
public EhcacheEntityResponse invokeAndWaitForComplete(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException {
71+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
72+
}
73+
74+
@Override
75+
public EhcacheEntityResponse invokeAndWaitForRetired(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException {
76+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
77+
}
78+
79+
@Override
80+
public EhcacheEntityResponse invokeStateRepositoryOperation(StateRepositoryOpMessage message, boolean track) throws ClusterException, TimeoutException {
81+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
82+
}
83+
84+
@Override
85+
public <T extends EhcacheEntityResponse> void addResponseListener(Class<T> responseType, ResponseListener<T> responseListener) {
86+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
87+
}
88+
89+
@Override
90+
public void addDisconnectionListener(DisconnectionListener disconnectionListener) {
91+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
92+
}
93+
94+
@Override
95+
public void addReconnectListener(ReconnectListener reconnectListener) {
96+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
97+
}
98+
99+
@Override
100+
public void enableEvents(boolean enable) throws ClusterException, TimeoutException {
101+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
102+
}
103+
104+
@Override
105+
public void close() {
106+
throw new FailedClusterTierException("Cache " + getCacheId() + " failed reconnecting to cluster", failure);
107+
}
108+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright Terracotta, Inc.
3+
* Copyright IBM Corp. 2024, 2025
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.ehcache.clustered.client.internal.reconnect;
18+
19+
import org.ehcache.clustered.client.config.Timeouts;
20+
import org.ehcache.clustered.client.internal.service.ClusterTierException;
21+
import org.ehcache.clustered.client.internal.store.ClusterTierClientEntity;
22+
import org.ehcache.clustered.client.internal.store.ReconnectInProgressException;
23+
import org.ehcache.clustered.common.internal.ServerStoreConfiguration;
24+
import org.ehcache.clustered.common.internal.exceptions.ClusterException;
25+
import org.ehcache.clustered.common.internal.messages.EhcacheEntityResponse;
26+
import org.ehcache.clustered.common.internal.messages.EhcacheOperationMessage;
27+
import org.ehcache.clustered.common.internal.messages.StateRepositoryOpMessage;
28+
29+
import java.util.concurrent.TimeoutException;
30+
31+
public class ReconnectInProgressClusterTierClientEntity implements ClusterTierClientEntity {
32+
33+
private volatile boolean isMarkedClose = false;
34+
35+
@Override
36+
public Timeouts getTimeouts() {
37+
throw new ReconnectInProgressException();
38+
}
39+
40+
@Override
41+
public boolean isConnected() {
42+
throw new ReconnectInProgressException();
43+
}
44+
45+
@Override
46+
public void validate(ServerStoreConfiguration clientStoreConfiguration) throws ClusterTierException, TimeoutException {
47+
throw new ReconnectInProgressException();
48+
}
49+
50+
@Override
51+
public void invokeAndWaitForSend(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException {
52+
throw new ReconnectInProgressException();
53+
}
54+
55+
@Override
56+
public void invokeAndWaitForReceive(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException {
57+
throw new ReconnectInProgressException();
58+
}
59+
60+
@Override
61+
public EhcacheEntityResponse invokeAndWaitForComplete(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException {
62+
throw new ReconnectInProgressException();
63+
}
64+
65+
@Override
66+
public EhcacheEntityResponse invokeAndWaitForRetired(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException {
67+
throw new ReconnectInProgressException();
68+
}
69+
70+
@Override
71+
public EhcacheEntityResponse invokeStateRepositoryOperation(StateRepositoryOpMessage message, boolean track) throws ClusterException, TimeoutException {
72+
throw new ReconnectInProgressException();
73+
}
74+
75+
@Override
76+
public <T extends EhcacheEntityResponse> void addResponseListener(Class<T> responseType, ResponseListener<T> responseListener) {
77+
throw new ReconnectInProgressException();
78+
}
79+
80+
@Override
81+
public void addDisconnectionListener(DisconnectionListener disconnectionListener) {
82+
throw new ReconnectInProgressException();
83+
}
84+
85+
@Override
86+
public void addReconnectListener(ReconnectListener reconnectListener) {
87+
throw new ReconnectInProgressException();
88+
}
89+
90+
@Override
91+
public void enableEvents(boolean enable) throws ClusterException, TimeoutException {
92+
throw new ReconnectInProgressException();
93+
}
94+
95+
@Override
96+
public void close() {
97+
isMarkedClose = true;
98+
}
99+
100+
public boolean checkIfClosed() {
101+
return isMarkedClose;
102+
}
103+
}

0 commit comments

Comments
 (0)