Giriş
XML konfigürasyonda sadece external-data-store-ref alanı mecburi. Gerisi isteğe bağlı
Örnek
Elimizde iki external data store olsun Burada isim olarak my-mysql-database kullanılıyor
<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>
my-mysql-database bağlantısını kullanmak şöyle yaparız.
<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>
Bu aslında şuna denk gelir. Burada TYPE değerinin JDBC olduğuna dikkat. Ayrıca mapping ismine __map-store ön eki ekleniyor.
CREATE MAPPING "__map-store.Foo" TYPE JDBC OPTIONS ( 'externalDataStoreRef' = 'my-mysql-database' )
Örnek - Sütun İsimleri Alanları
Şöyle yaparız
<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>
Bu sefer Hazelcast içinde yaratılan tablo şöyle
Örnek - id-column
Şöyle yaparız
<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>
Hiç yorum yok:
Yorum Gönder