DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

The Latest Software Design and Architecture Topics

article thumbnail
Making the Case For and Against Lift-and-Shift Cloud Migration
A common approach to cloud migration is to simply port material to the cloud, which is not always the best decision, considering the complexity of modern apps.
December 17, 2016
by Darren Perucci
· 11,218 Views · 3 Likes
article thumbnail
Complex Event Processing - Using Drools Fusion
Drools can help you process streams to perform tasks such as threat detection, real-time event monitoring, tracking user behavior, and more.
December 16, 2016
by Sumith Puri
· 18,773 Views · 2 Likes
article thumbnail
A Deep Dive Into Couchbase N1QL Query Optimization
This comprehensive guide to N1QL queries covers the ins and outs of the query engine, teaching users about how to efficiently scan and join data.
December 16, 2016
by Keshav Murthy DZone Core CORE
· 16,955 Views · 9 Likes
article thumbnail
Testing Spring MVC With Spring Boot 1.4: Part I
If you’re looking to load your full app configuration and use MockMVC, you should consider @SpringBootTest combined with @AutoConfigureMockMvc rather than @WebMvcTest.
December 16, 2016
by John Thompson
· 35,688 Views · 8 Likes
article thumbnail
What is Mobile Development?
Interested in why you're developing on the platforms you do? Or why you're using the tools you have?
December 16, 2016
by John Sonmez
· 21,703 Views · 3 Likes
article thumbnail
From Solr Master-Slave to the (Solr)Cloud
If you're moving to Solr's distributed search system, there's a lot to keep in mind ranging from indexing differences to testing procedures to keeping ZooKeeper working.
December 15, 2016
by Rafał Kuć
· 7,864 Views · 1 Like
article thumbnail
How to Create a Template Project With Anypoint Studio and Mulesoft Exchange
You write process APIs by making a template process API and template item in Mulesoft Exchange.
December 15, 2016
by Jos Aikema
· 15,588 Views · 5 Likes
article thumbnail
An Overview of Meta-Monitoring
Meta-monitoring is basically self-service for monitoring. There are several different requirements and methods that should be kept in mind when it comes to meta-monitoring.
December 15, 2016
by Thomas Kurian Theakanath
· 6,060 Views · 2 Likes
article thumbnail
How SAML Authentication Works
This comprehensive guide to SAML covers how the authentication protocol works, how requests are generated and read, and what tools can help you keep projects secure.
December 15, 2016
by Prosper Otemuyiwa
· 90,739 Views · 12 Likes
article thumbnail
JSON-B: A Java API for JSON Binding
When JSON-B and JSON-P are combined, all of the tools are put in place to process and work with the JSON data format in Java.
December 14, 2016
by Sam Sepassi
· 23,245 Views · 6 Likes
article thumbnail
Deploying Microservices: Spring Cloud vs. Kubernetes
When it comes to deploying microservices, which is better — Spring Cloud or Kubernetes? The answer is both, but they shine in different ways.
December 13, 2016
by Bilgin Ibryam
· 196,684 Views · 104 Likes
article thumbnail
Making Elasticsearch in Docker Swarm Truly Elastic
Running a truly elastic Elasticsearch cluster on Docker Swarm is hard. Here's how to get past Elasticsearch and Docker's pitfalls with IP addresses, networking, and more.
December 13, 2016
by Stefan Thies
· 13,876 Views · 14 Likes
article thumbnail
How Small Should Microservices Be?
There are tons of different perspectives regarding the best size and granularity of microservices. Which perspective is best for your project?
December 12, 2016
by Grygoriy Gonchar
· 16,297 Views · 8 Likes
article thumbnail
Technical Spikes in DevOps
The true technical spike is a last resort and happens as infrequently as possible. It is a refinement activity that allows the backlog to be understood for future planning.
December 12, 2016
by $$anonymous$$
· 14,046 Views · 1 Like
article thumbnail
About the Java 8 Stream API Bug
The Java Stream API wasn't working the way it was supposed to. There is a fix, but it's interesting to see what exactly went wrong.
December 12, 2016
by A N M Bazlur Rahman DZone Core CORE
· 16,938 Views · 17 Likes
article thumbnail
How to Use Asynchronous Timeouts in the Java Websocket API
In this post we take a look at how to deal with timeouts when using the Java WebSocket API. Read on to find out how and for some example code.
December 10, 2016
by Abhishek Gupta DZone Core CORE
· 12,392 Views · 4 Likes
article thumbnail
Mastering the Couchbase N1QL Shell: Connection Management and Security
Couchbase's cbq shell lets you write and run N1QL queries interactively. The shell also lets you securely interact with mixed nodes, among other handy tricks.
December 9, 2016
by Isha Kandaswamy
· 8,730 Views · 5 Likes
article thumbnail
Create a REST API with Speedment and Spring
You can build a complete REST API with almost no manual coding using open-source Speedment and Spring.
December 9, 2016
by Emil Forslund
· 12,585 Views · 7 Likes
article thumbnail
ConcurrentHashMap isn't always enough
When Java developers come to a task of writing a a new class which should have a Map datastructure field, accessed simultaneously by several threads, they usually try to solve the synchronization issues invloved in such a scenario by simply making the map an instance of ConcurrentHashMap . public class Foo { private Map theMap = new ConcurrentHashMap<>(); // the rest of the class goes here... } In many cases it works fine just because the contract of ConcurrentHashMap takes care of the potential synchronization issues related to reading/writing to the map. But there are cases where it's not enough, and a developer gets race conditions which are hard to predict, and even harder to find/debug and fix. Let's have a look, at the next example: public class Foo { private Map theMap = new ConcurrentHashMap<>(); public Object getOrCreate(String key) { Object value = theMap.get(key); if (value == null) { value = new Object(); theMap.put(key, value); } return value; } } Here we have a "simple" getter ( getOrCreate(String key) ), which gets a key and returns the value assosiated with the given key in theMap . If there is no mapping for the key, the method creates a new value, inserts it into theMap and returns it. So far so good. But what happens when 2 (or more) threads call the getter with the same key when there is no mapping for the key in theMap? In such a case we might receive a race condition: Suppose thread t1 enters the function and comes to line 7. Its value is null . At this point thread t2 enters the function and also comes to line 7. Its value is also obviously null . Therefore from this point the two threads will enter the if statement and execute lines 8 and 9, thus creating two different new Objects. Upon returning from the getter each thread will get a different Object instance, violating programmer's wrong assumption that by using ConcurrentHashMap "everything is synchronized" and therefore two different threads should get the same value for the same key. To solve this issue we can synchronize the entire method, thus making it atomic: public class Foo { private Map theMap = new ConcurrentHashMap<>(); public synchronized Object getOrCreate(String key) { Object value = theMap.get(key); if (value == null) { value = new Object(); theMap.put(key, value); } return value; } } But this is a bit ugly, and uses Foo instace's monitor, which may affect performance if there are other methods in this class which are synchronized. Also a common rule of thumb is to try to eliminate using synchronized methods as much as possible. A much better approach should be using Java 8 Map's computeIfAbsent(K key, Function mappingFunction), which, in ConcurrentHashMap's implementation runs atomically: public class Foo { private Map theMap = new ConcurrentHashMap<>(); public Object getOrCreate(String key) { return theMap.computeIfAbsent(key, k -> new Object()); } } The atomicity of computeIfAbsent(..) assures that only one new Object will be created and put into theMap, and it'll be the exact same instance of Object that will be returned to all threads calling the getOrCreate function. Here, not only the code is correct, it's also cleaner and much shorter. The point of this example was to introduce a common pitfall of blindly relying on ConcurrentHashMap as a majical synchronzed datastructure which is threadsafe and therefore should solve all our concurrency issues regarding multiple threads working on a shared Map. ConcurrentHashMap is, indeed, threadsafe. But it only means that all read/write operations on such map are internally synchronized. And sometimes it's just not enough for our concurrent environment needs, and we have to use some special treatment which will guarantee atomic execution. A good practice will be to use one of the atomic methods implemented by ConcurrentHashMap, i.e: computeIfAbsent(..), putIfAbsent(..), etc.
December 8, 2016
by Dima Leah
· 48,911 Views · 12 Likes
article thumbnail
Message-Based Security for SOAP in webMethods: Part I
Learn how to place policies under Integration Server, attach a policy to web service descriptor, and pass message-based authentication credentials with web service.
December 8, 2016
by Prasad Pokala
· 8,203 Views · 7 Likes
  • Previous
  • ...
  • 684
  • 685
  • 686
  • 687
  • 688
  • 689
  • 690
  • 691
  • 692
  • 693
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×