Şöyle yaparız
sql> SHOW DATA CONNECTIONS;+--------------------+----------------------------------------+|name |types |+--------------------+----------------------------------------++--------------------+----------------------------------------+
sql> SHOW DATA CONNECTIONS;+--------------------+----------------------------------------+|name |types |+--------------------+----------------------------------------++--------------------+----------------------------------------+
import com.hazelcast.dataconnection.impl.DataConnectionService;
DagBuildContext context = ...; JdbcDataConnection dataConnection = context .getNodeEngine() .getDataConnectionService() .getAndRetainDataConnection(dataConnectionName, JdbcDataConnection.class);
CREATE DATA CONNECTION IF NOT EXISTS maria TYPE Jdbc SHARED OPTIONS ( 'jdbcUrl' = 'jdbc:mariadb://35.195.166.24:3306/transaction-monitor-payments', 'user' = 'admin', 'password' = 'password1' )
CREATE DATA CONNECTION mysql2 TYPE JDBC NOT SHARED OPTIONS('jdbcUrl'='jdbc:mysql://localhost:3306/mydb', 'user'='root', 'password'='123');
CREATE DATA CONNECTION mysql2 TYPE JDBC SHARED OPTIONS('jdbcUrl'='jdbc:mysql://localhost:3306/mydb', 'user'='root', 'password'='123');
import com.hazelcast.jet.core.processor.SourceProcessors;
public static ProcessorMetaSupplier readMapP(String mapName);
public static <K, V> ProcessorMetaSupplier streamMapP( String mapName, JournalInitialPosition initialPos, EventTimePolicy<? super Entry<K, V>> eventTimePolicy )
import com.hazelcast.jet.pipeline.test.AssertionSinks;
Pipeline pipeline = Pipeline.create(); ... .writeTo(Sinks.logger()); .writeTo(AssertionSinks.assertCollectedEventually(60, list -> assertEquals(100, list.size())));
clc -c sqltest sql "SELECT * FROM abc"
clc completion --help
clc completion bash --help
clc map set -n mymap "mykey" "myvalue" --log.path stderr clc map get -n mymap "mykey"--log.path stderr
<hazelcast> <external-data-store name="my-mysql-database"> <class-name>com.hazelcast.datastore.JdbcDataStoreFactory</class-name> <properties> <property name="jdbcUrl">jdbc:mysql://mysql.example.org:3306</property> <property name="username">my_user</property> <property name="password">my_password</property> </properties> <shared>true</shared> </external-data-store> <external-data-store name="my-other-database"> <class-name>com.hazelcast.datastore.JdbcDataStoreFactory</class-name> <properties> <property name="jdbcUrl">jdbc:h2:mem:my-other-database</property> </properties> <shared>true</shared> </external-data-store> </hazelcast>
<hazelcast> <map name="Foo"> <map-store enabled="true"> <class-name>com.hazelcast.mapstore.GenericMapStore</class-name> <properties> <property name="external-data-store-ref">my-mysql-database</property> </properties> </map-store> </hazelcast>
CREATE MAPPING "__map-store.Foo" TYPE JDBC OPTIONS ( 'externalDataStoreRef' = 'my-mysql-database' )
<map name=“Staff”> <map-store enabled=“true”> <class-name>com.hazelcast.mapstore.GenericMapStore</class-name> <properties> <property name=“external-data-store-ref”>my-mysql-database</property> <property name=“table-name”>employee</property> <property name=“id-column”>empId</property> <property name=“columns”>empName</property> </properties> </map-store> </map>
<map name="shipstaticdata"> <map-store enabled="true"> <class-name>com.hazelcast.mapstore.GenericMapStore</class-name> <properties> <property name="external-data-store-ref">postgresdb</property> <property name="mapping-type">JDBC</property> <property name="id-column">name</property> </properties> </map-store> </map> <external-data-store name="postgresdb"> <class-name>com.hazelcast.datastore.JdbcDataStoreFactory</class-name> <properties> <property name="jdbcUrl">jdbc:postgresql://localhost:5432/aisdata</property> <property name="username">postgres</property> <property name="password">NuZ8QxaXpjyxvlmL</property> </properties> <shared>true</shared> </external-data-store>
import com.hazelcast.map.impl.MapStoreWrapper;
public class MapStoreWrapper implements MapStore, MapLoaderLifecycleSupport { /** * An instance of {@link MapLoader} configured for this map * or {@code null} if none was provided. */ private MapLoader mapLoader; /** * An instance of {@link MapStore} configured for this map * or {@code null} if none was provided. */ private MapStore mapStore; private boolean withExpirationTime; private final String mapName; private final Object impl; ... }
import com.hazelcast.internal.serialization.DataSerializerHook;
In Hazelcast, a DataSerializerHook is a mechanism to register custom serializers for objects that are not natively serializable....The DataSerializerHook is an interface that you can implement to register custom serializers for your objects. You can use this interface to define how your objects will be serialized and deserialized. When Hazelcast encounters an object that needs to be serialized or deserialized, it will check if a serializer is registered for that object. If there is a serializer, Hazelcast will use it to convert the object into a format that can be transmitted over the network. If there is no serializer, Hazelcast will throw an exception.
void loadAll(boolean replaceExistingValues);void loadAll(@Nonnull Set<K> keys, boolean replaceExistingValues);
public void entryExpired(EntryEvent<String, Claim> event) {...}
public abstract class JdbcSqlTestSupport extends SqlTestSupport {public static void initialize(TestDatabaseProvider provider) { initialize(provider, smallInstanceConfig()); } ... }
Currently, two tables are exposed:mappings: contains information about existing mappingscolumns: contains information about mapping columns
String query = "SELECT * FROM information_schema.columns WHERE table_name = ? ORDER BY ordinal_position ASC"; try (SqlResult result = sqlService.execute(query, mapping)) { return StreamSupport .stream(result.spliterator(), false) .map(row -> { String name = row.getObject("column_name"); SqlColumnType type = SqlColumnType.valueOf(row.getObject("data_type")); boolean isNullable = Boolean.parseBoolean(row.getObject("is_nullable")); return new SqlColumnMetadata(name, type, isNullable); }) .collect(Collectors.toList()); }
{ "valueFormat":"json-flat", "bootstrap.servers":""a.b.c.d:9092", "security.protocol":"SASL_SSL", "sasl.jaas.config":"org.apache.kafka.common.security.plain.PlainLoginModule required username="..." password="...";", "sasl.mechanism":"PLAIN", "auto.offset.reset":"earliest" }"
SELECT table_name, mapping_external_name, mapping_type FROM information_schema.mappings
import com.hazelcast.config.PermissionConfig;
public class JetUploadJobMetaDataTask extends AbstractJetMessageTask<JetUploadJobMetaDataCodec.RequestParameters, Boolean> { @Override public String[] actions() { return new String[]{ActionConstants.ACTION_SUBMIT}; } ... }
abstract class AbstractJetMessageTask<P, R> extends AbstractInvocationMessageTask<P> { @Override public final Permission getRequiredPermission() { String[] actions = actions(); if (actions != null) { return new JobPermission(actions); } return null; } ... }
Config config = ...; SecurityConfig securityConfig = config.getSecurityConfig(); securityConfig.setEnabled(true); String principal = "dev" securityConfig.addClientPermissionConfig( new PermissionConfig(PermissionConfig.JOB, "", principal) .addAction(ActionConstants.ACTION_SUBMIT)); securityConfig.addClientPermissionConfig( new PermissionConfig(PermissionConfig.ALL, "", principal) .addAction(ActionConstants.ACTION_ALL));
import com.hazelcast.jet.Traversers;
public static <T> Traverser<T> traverseStream(@Nonnull Stream<T> stream) { return traverseSpliterator(stream.spliterator()).onFirstNull(stream::close); }
private static class SpliteratorTraverser<T> implements Traverser<T>, Consumer<T> { private final Spliterator<T> spliterator; private T nextItem; SpliteratorTraverser(Spliterator<T> spliterator) { this.spliterator = spliterator; } @Override public T next() { try { boolean advanced = spliterator.tryAdvance(this); if (advanced) { requireNonNull(nextItem); } return nextItem; } finally { nextItem = null; // Burada nesneyi null yap } } @Override public void accept(T t) { nextItem = t; } }
public static <T> Traverser<T> traverseIterable(Iterable<? extends T> iterable)
import com.hazelcast.instance.AddressPicker;
NetworkConfig networkConfig = config.getNetworkConfig(); networkConfig.setPublicAddress("localhost"); DefaultAddressPicker addressPicker = new DefaultAddressPicker(config, logger); addressPicker.pickAddress(); // localhost:5701 Address actual = addressPicker.getPublicAddress(null);
import com.hazelcast.core.DistributedObject;
HazelcastInstance hazelcastInstance = HazelcastClient.newHazelcastClient();Collection<DistributedObject> distributedObjects = hazelcastInstance .getDistributedObjects();for (DistributedObject object : distributedObjects) {if (object instanceof IMap) {IMap map = hazelcastInstance.getMap(object.getName());System.out.println("Mapname=" + map.getName());map.entrySet().forEach(System.out::println);}}hazelcastInstance.shutdown();
import com.hazelcast.topic.ITopic;
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
ITopic<Long> topic = hz.getReliableTopic("sometopic");
long messageId = ...;
topic.publish(messageId);
public class Trader {
private HazelcastInstance hazelcast;
private ITopic<TradeMessage> tradeTopic;
public Trader() {
hazelcast = Hazelcast.newHazelcastInstance();
tradeTopic = hazelcast.getTopic("trades");
}
public void trade(String symbol, int quantity, double price) {
TradeMessage trade = new TradeMessage(symbol, quantity, price);
tradeTopic.publish(trade);
}
}
public class TradeListener implements MessageListener<TradeMessage> {
private HazelcastInstance hazelcast;
private ITopic<TradeMessage> tradeTopic;
public TradeListener() {
hazelcast = Hazelcast.newHazelcastInstance();
tradeTopic = hazelcast.getTopic("trades");
tradeTopic.addMessageListener(this);
}
public void onMessage(Message<TradeMessage> message) {
TradeMessage trade = message.getMessageObject();
}
}
ITopic topic = ...;
topic.publish(objectToStore);
HazelcastInstance hazelcastInstance = ...;
ITopic topic = hazelcastInstance.getReliableTopic("topic_name");
String listenerId = topic.addMessageListener(new TopicListener());
topic.removeMessageListener(listenerId);
class TopicListener implements MessageListener {
@Override
public void onMessage(Message message) {}
}
Kullanılan harici kütüphanelerin sürümleri bu dosyada Dosyanın yolu şöyle hazelcast/licenses/THIRD-PARTY.txt