sterowniki .net i c++ dla apache cassandra
DESCRIPTION
Prezentacja przygotowana przez dr inż. Pawła Kapłańskiego na Warsaw Cassandra User GroupTRANSCRIPT
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Sterowniki .NET i C++ dla Apache Cassandra
dr inż. Paweł Kapłański
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
CognitumAutoryzowany dystrybutor DataStax Enterprise w Polsce
Dostarczamy:
Wysoce skalowalne aplikacje w chmurze
Rozwiązania Big Data
Systemy zarządzania wiedzą
Aplikacje dedykowane
Rozwój oprogramowania i testowanie aplikacji
Konsulting IT
strong partnerships:
Customers from: US, CH, FL, DE
Big Data
Cloud
Semantics
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Spis treści (Agenda)1. Cassandra
2. Jak działają stare sterowniki oparte o Thrift
3. Asynchroniczność
4. Binarny protokół klient-serwer w Cassandrze
5. Przykład (driver .Net)
6. Plany na przyszłość
7. Driver C++
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Cassandra1. noSql – BigTable (Google 2005)
2. Stworzona w FB – obecnie Apache
3. Rozproszona
4. Skalowalna - Duże (100PB) dane
5. Obecnie już istnieją instalacje po 1000 nodów
6. Symetryczna (odporna na awarie)
7. Klaster (możliwość instalacji „multidatacenter”)
8. Elastyczna – duże możliwości konfiguracji
9. CQL – Cassandra Query Language – podobny do SQL
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Multidatacenter
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Typowa aplikacja (serwis www .Net)
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Ważne!1. Driver to nie tyko „smart socket” - posiada
rozbudowaną logikę działania2. Driver zarządza połączeniami do klastra
– load balancer3. Użytkownik nie musi martwić się o
połączenie i strategię – wystarczy ze użyje jednej z dostaraczanych np. RoundRobin
4. Driver potrafi automatycznie powtórzyć zapytanie w razie potrzeby
5. Można tworzyć własne strategie6. Lock-free (wysoka wydajność)
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Interfejsy C*: Thrift1. IDL (interface definition language)
2. Pozwala na automatyczne generowanie kodu w różnych językach
3. Sam Thrift to nie wszystko – trzeba obsłużyć zapytania do klastra
4. Zapytanie blokuje połączenie (podobnie jak zapytanie http) w oczekiwaniu na odpowiedź
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Interfejsy C*: Protokół binarny1. Operacje asynchroniczne
2. Pojedyncze polaczenie do 128 jednoczesnych zapytan
3. Lepsze wykorzystanie zasobów (połączenia są kosztowne)
4. Cassandra może lepiej optymizować
5. Wsparcie dla programowania asynchronicznego – powszechne obecnie w podejsciu client-server
6. Zdarzenia z Cassandy są „pushowane”
• zmiana schematu bazy
• zmiana w topologii klastra
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Wspierane języki1. Native Protocol Drivers (Datastax)
• Java driver (with ORM)
• .Net driver (Cql2Linq, ORM)
• Python
• C++ Driver – early stage of development
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Przykład – połączenie (driver .Net)1. public class NerdMovie {
[PartitionKey] public string Movie;
[ClusteringKey(1)] public string Director;
public string MainActor;
public int Year;
}
2. var cluster = Cluster.Builder().AddContactPoints("192.168.13.1", "192.168.13.1").Build();
3. using (var session = cluster.Connect("test")){ var nerdMovieTable = session.GetTable<NerdMovie>(); nerdMovieTable.CreateIfNotExists();
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Zapytaniavar batch = session.CreateBatch();
batch.Append(nerdMovieTable.Insert(
new NerdMovie() { Movie = "Serenity", Director = "Joss Whedon", MainActor = "Nathan Fillion", Year = 2005 }));
batch.Append(nerdMovieTable.Insert(
new NerdMovie() { Movie = "Pulp Fiction", Director = "Quentin Tarantino", MainActor = "John Travolta", Year = 1994 }));
batch.Append(nerdMovieTable.Insert(
new NerdMovie() { Movie = "Zero Charisma", Director = "Katie Graham", MainActor = "Nathan Fillion", Year = 2013 }));
var query = from m in nerdMovieTable select m;
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Wywołanie synchronicznebatch.Execute();
var result = query.Execute();
foreach (var e in result)
Console.WriteLine("Movie " + e.Movie + "[" + e.Director + "]");
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Wywołanie asynchroniczneManualResetEventSlim ev = new ManualResetEventSlim();
batch.BeginExecute((ar1) => {
batch.EndExecute(ar1);
query.BeginExecute((ar2) => {
var result = query.EndExecute(ar2);
foreach (var e in result)
Console.WriteLine("Movie " + e.Movie + "[" + e.Director + "]");
ev.Set();
}, null);
}, null);
ev.Wait();
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Co dalej? (driver .Net)Protokół binarny: wersja 2 (Cassandra 2.x)
- Batch
- Autentykacja poprzez SASL
- Lekkie transakcje – implementacja protokołu Paxos
IINSER … IF NOT EXISTS, UPDATE … IF
<column>=<value>
- Strumieniowanie wyników
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Driver C++ (w drodze)
1. Wieloplatformowość (np. embedded)
2. Oparty o boost::asio3. Mała liczba zależności od innych
bibliotek
www.cognitum.eu The company, product and service names used in this web site are for identification purposes only. All trademarks and registered trademarks are the property of their
respective owners.
Kontakt
Cognitum | CH, St. [email protected]
abroad sales representatives:
Cognitum | PL, [email protected]+48 22 250 2541
www.cognitum.eu/semantics
Cognitum | UK, [email protected]