Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the Design of java Fuse

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to realize java fuse design". In daily operation, I believe many people have doubts about how to realize java fuse design. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts about "how to realize java fuse design"! Next, please follow the small series to learn together!

state mode

We have an example of a switch

In each state, context doesn't have to care about behavior in each state. Let each state handle itself.

Basic principles of fuses

Fuse is when the dependent service has failed, in order to ensure the normal operation of its own service, no longer access to the dependent service, to prevent avalanche effect

The fuse itself is a state machine.

Closed state: The initialized state of a fuse in which requests are allowed to pass. When the failure exceeds the threshold, it turns to the open state,

Open state: fused state, this state does not allow requests to pass, when entering this state after a period of time, into the semi-open state.

Half-open state: During the half-open state, some requests are allowed to pass. During the half-open state, observe whether the failure state exceeds the threshold. If it is not exceeded, enter the closed state. And so on.

Before that, I checked some information. Almost all the information on the Internet was aimed at Hystrix. This is only an interface request for distributed systems, and can not be applied to our system, so in this case, according to the principle of their own implementation of a basic distributed fuse, the value and counter stored in redis, because redis operating client is not the same, I will take the local fuse as an example to explain the fuse implementation.

I hope my article will be helpful to understand fuses and those who need them.

Simple local fuse implementation

A basic local fuse.

image.png

externally exposed interface

External exposed interface of fuse

External exposure interface of fuse state

three states

Close state realization:

open state

half-open state

fuse

abstract fuse

local fuse

test example

results

At this point, the study of "how to realize java fuse design" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report