com.hazelcast.client.cp.internal.CPSubsystemImpl Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2008-2020, Hazelcast, Inc. All Rights Reserved.
*
* 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 com.hazelcast.client.cp.internal;
import com.hazelcast.client.cp.internal.datastructures.proxy.ClientRaftProxyFactory;
import com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl;
import com.hazelcast.client.spi.ClientContext;
import com.hazelcast.core.IAtomicLong;
import com.hazelcast.core.IAtomicReference;
import com.hazelcast.core.ICountDownLatch;
import com.hazelcast.core.ISemaphore;
import com.hazelcast.cp.CPMember;
import com.hazelcast.cp.CPSubsystem;
import com.hazelcast.cp.CPSubsystemManagementService;
import com.hazelcast.cp.internal.datastructures.atomiclong.RaftAtomicLongService;
import com.hazelcast.cp.internal.datastructures.atomicref.RaftAtomicRefService;
import com.hazelcast.cp.internal.datastructures.countdownlatch.RaftCountDownLatchService;
import com.hazelcast.cp.internal.datastructures.lock.RaftLockService;
import com.hazelcast.cp.internal.datastructures.semaphore.RaftSemaphoreService;
import com.hazelcast.cp.lock.FencedLock;
import com.hazelcast.cp.session.CPSessionManagementService;
/**
* Client-side impl of the CP subsystem to create CP data structure proxies
*/
public class CPSubsystemImpl implements CPSubsystem {
private final ClientRaftProxyFactory proxyFactory;
public CPSubsystemImpl(HazelcastClientInstanceImpl client) {
this.proxyFactory = new ClientRaftProxyFactory(client);
}
public void init(ClientContext context) {
proxyFactory.init(context);
}
@Override
public IAtomicLong getAtomicLong(String name) {
return proxyFactory.createProxy(RaftAtomicLongService.SERVICE_NAME, name);
}
@Override
public IAtomicReference getAtomicReference(String name) {
return proxyFactory.createProxy(RaftAtomicRefService.SERVICE_NAME, name);
}
@Override
public ICountDownLatch getCountDownLatch(String name) {
return proxyFactory.createProxy(RaftCountDownLatchService.SERVICE_NAME, name);
}
@Override
public FencedLock getLock(String name) {
return proxyFactory.createProxy(RaftLockService.SERVICE_NAME, name);
}
@Override
public ISemaphore getSemaphore(String name) {
return proxyFactory.createProxy(RaftSemaphoreService.SERVICE_NAME, name);
}
@Override
public CPMember getLocalCPMember() {
throw new UnsupportedOperationException();
}
@Override
public CPSubsystemManagementService getCPSubsystemManagementService() {
throw new UnsupportedOperationException();
}
@Override
public CPSessionManagementService getCPSessionManagementService() {
throw new UnsupportedOperationException();
}
}