博文

distributed transaction solution - Seata

 Distributed Transaction Solution GTS(Global Transaction Service) ACID XA(eXtended Architecture) X/Open. TM(Transaction Manager), RM(Resource Manager), and Application Manager. XA->2PC(Prepare, commit, rollback)->TCC(Try,Confirm,Canccel)->3PC(CanCommit,PreCommit,DoCommit) Saga , 1987 year, by Hector and Kenneth for Long lived transaction. Princeton University Seata TXC->GTS->Seata->Seata GA TC(Transaction Coordinator),TM(Transaction Manager),RM(Resource Manager). http://seata.io/en-us/docs/overview/what-is-seata.html XID - Transaction ID TC - Transaction Coordinator Maintain status of global and branch transactions, drive the global commit or rollback. TM - Transaction Manager Define the scope of global transaction: begin a global transaction, commit or rollback a global transaction. RM - Resource Manager Manage resources that branch transactions working on, talk to TC for registering branch transactions and reporting status of branch transactions, and driv...

CAP, Consistency, Availability, Partition tolerance & ES, Elastic Search

 CAP, Consistency, Availability, Partition tolerance Consistency Consistency means that all clients see the same data at the same time, no matter which node they connect to. For this to happen, whenever data is written to one node, it must be instantly forwarded or replicated to all the other nodes in the system before the write is deemed ‘successful.’ Availability Availability means that that any client making a request for data gets a response, even if one or more nodes are down. Another way to state this—all working nodes in the distributed system return a valid response for any request, without exception. Partition tolerance A partition is a communications break within a distributed system—a lost or temporarily delayed connection between two nodes. Partition tolerance means that the cluster must continue to work despite any number of communication breakdowns between nodes in the system. From: https://www.ibm.com/cloud/learn/cap-theorem CA: Oracle, My SQL; A...

Android-Command line tools

 Android-Command line tools 1.mkdir Hello 2.cd Hello\ 3.mkdir src\dom\domain 4.vim src\dom\domain\SayingHello.java vim >  package dom.domain; import android.widget.TextView; public final class SayingHello extends android.app.Activity { public void onCreate( final android.os.Bundle activityState ) { super.onCreate( activityState ); final TextView textV = new TextView( SayingHello.this ); textV.setText( "Hello world" ); setContentView( textV ); } } vim > :wq 5.vim AndroidManifest.xml vim >  <?xml version='1.0'?> <manifest xmlns:a='http://schemas.android.com/apk/res/android' package='dom.domain' a:versionCode='0' a:versionName='0'> <application a:label='Saying hello'> <activity a:name='dom.domain.SayingHello'> <intent-filter> <category a:name='android.intent...

Await - Async in C#

  await - async  in C# WPF Sample1:  without UI controll var webclient = new WebClient(); var downThread = new Thread( ()=> { var result = webclient.DownloadString("http://www.google.com"); MessageBox.Show(result); }); downThread.Start(); Sample2: still without UI controll. runButton.IsEnabled= false; var webclient = new WebClient(); var downThread = new Thread( ()=> { var result = webclient.DownloadString("http://www.google.com"); MessageBox.Show(result); }); downThread.Start(); runButton.IsEnabled= true; Sample3: error. runButton.IsEnabled= false; var webclient = new WebClient(); var downThread = new Thread( ()=> {     var result = webclient.DownloadString("http://www.google.com");     MessageBox.Show(result);     runButton.IsEnabled= true;  // is going to crash. error . }); downThread.Start(); Sample4: Dispatcher.Invoke runButton.IsEnabled= false; var webclient = new WebClient(); var downThread = new Thread( (...

Jackson in Java for JSON

Jackson, https://github.com/FasterXML/jackson Jackson has been known as "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java". Jackson 3 core libs:streaming,databind,annotations. Jackson version: 1.x: org.codehaus.jackson.xxx;  2.x: com. fastxml .jackson.xxx To capitalize the first letter, you need the following: 1. Maven adds: <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.3</version> </dependency> 2. Add to the attributes: @JsonProperty( "Code") 3. Add to the Getter method: @JsonIgnore To implement toString()  import com.alibaba.fastjson.annotation. JSONField ; import com.fasterxml.jackson.annotation. JsonIgnore ; import com.fasterxml.jackson.annotation. JsonProperty ; import net.sf.json.JSONObject ; @Override public String toString () { return JSONObje...