|
| 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 | +} |
0 commit comments