Simulating and Troubleshooting Blocked Threads in Scala [Video]

In this series of simulating and troubleshooting performance problems in Scala, let’s discuss how to make threads go into a blocked state. A thread will enter into a blocked state when it cannot acquire a lock on an object because another thread already holds the lock on the same object and doesn’t release it.
Stop graphic

Scala Blocked Thread Program

Here is a sample program, which would make threads go into a blocked state.

How To Scan and Validate Image Uploads in Java

Direct image upload processes create a highly efficient path between client-side users and a website’s underlying file storage instances, significantly benefiting both ends of the client/web service relationship. Due largely to the ever-increasing availability (and affordability) of cloud storage resources for independent developer projects and small business ventures, we see the option to upload our own image files more and more frequently everywhere we look online, growing in tandem with steady demand for new forms of social engagement and commerce.

The trouble is, however, that file upload security is a very serious issue - and image files are rather easily exploited by client-side threat actors. Image files aren’t unique in this respect, of course (many common file formats including PDF, DOCX, etc., for example, can house a variety of hidden threats), but their monumental value on the internet – a mostly visual platform – sets them apart as one of the more expedient vessels for malicious content.  

Batch Request Processing With API Gateway

Batch request processing is a powerful technique used in web development to improve the performance of APIs. It allows developers to group multiple API requests into a single HTTP request/response cycle. In other words, a single API request from a client can be turned into multiple API requests to a set of backend servers, and the responses are aggregated into a single response to the client. It can significantly reduce the number of round trips between the client and server.

In this article, we'll explore how to implement batch request processing in Apache APISIX and look at some use cases where it can be beneficial.

Brilliant Home Technology

What were once pipe dreams of The Jetsons’ smart home quickly found in nearly all modern triplex. The technology allows for many automated functions, such as setting up the house alarm, turning over the lights, and playing your preferred music at the motivate of a button. Not only is it a cool feature that can …

Brilliant Home Technology Read More »

Business Computing and Commodity Computer software

Business computing encompasses the usage of computer technology for the purpose of managing a business getboardroom.net/best-business-desktop-pc organization operations. Common tasks include media production, employee connection through email and other messaging systems, monitoring customer info or maintaining accounting devices. Some firms also use personal computers to research industry trends, us patents and logos as well as …

Business Computing and Commodity Computer software Read More »

Process Flow for Deployment in DevOps

The DevOps deployment process is a continuous delivery model that streamlines software development, testing, and deployment through automation and collaboration between development and operations teams. DevOps has become increasingly popular in recent years due to its ability to deliver high-quality software quickly and efficiently.

In this article, we'll discuss the various stages of the DevOps deployment process, the tools used, and best practices for successful implementation.

Maximizing API Success: The Importance of Wireframing and Modeling

So, you're developing an API alongside a mobile or web interface? Well, wireframing the user interface is going to be your new best friend. These wireframes won't give you every feature you need, but they will help you focus on what's important: what the end user wants to do and how they want to do it. Trust us, this will have a huge impact on your API. The user interface requires more complex interactions, which means your API will need to support those interactions. 

Don't be fooled into thinking that your API only needs simple data-access functionality. The gaps in your API will be revealed through the user interface. It will also show you how many API calls are required to accomplish a given task. In mobile applications, every HTTP call to an API takes place over an unreliable cellular network, making this particularly crucial. 

FileNet Integration Process

FileNet is an enterprise content management (ECM) platform developed by IBM. It provides various tools and services for managing content, processes, and workflows within an organization.

Documentum product is an enterprise content management (ECM) platform. It provides a wide range of tools and services for managing content and information in organizations. Documentum was originally developed by Documentum, Inc. and was later acquired by EMC Corporation, which was, in turn, acquired by Dell Technologies. Below are some of the benefits of migrating FileNet into Documentum.

How To Boost AI Model Training With a Distributed Storage System

Traditional machine-learning models can be stored on standalone machines or local hard drives when working with small datasets and simple algorithms. However, as deep learning advances, teams increasingly encounter storage bottlenecks when handling larger datasets and more complex algorithms.

This highlights the importance of distributed storage in the artificial intelligence (AI) field. JuiceFS, an open-source, high-performance distributed file system, provides a solution to this problem.

SASE: The Ultimate Guide To Secure Access Service Edge

As enterprises move towards the cloud and mobility becomes the norm, networking and security solutions must evolve accordingly. Secure Access Service Edge (SASE) enters the picture here. SASE is an up-and-coming technology category that aims to offer specific network security features. 

The Secure Access Service Edge (SASE) architecture reduces external traffic normally sent back to the data center. This article will delve into the definition of SASE, the problems it solves, and its benefits and drawbacks.

ShardingSphere’s Built-In Metadata Handling Function for Sharded Database Environments

Apache ShardingSphere is a widely recognized and trusted open-source data management platform that provides robust support for key functionalities such as sharding, encryption, read/write splitting, transactions, and high availability. The metadata of ShardingSphere encompasses essential components such as rules, data sources, and table structures, which are fundamental for the smooth operation of the platform. ShardingSphere leverages the advanced capabilities of governance centers like ZooKeeper and etc., for efficient sharing and modification of cluster configurations, enabling seamless horizontal expansion of computing nodes. 

In this informative blog post, our emphasis will be on gaining a comprehensive understanding of the metadata structure employed by Apache ShardingSphere. We will delve into the intricacies of the three-layer metadata structure within ZooKeeper, which encompasses crucial components such as metadata information, built-in metadata database, and simulated MySQL database.

Metadata Structure

For a comprehensive grasp of the metadata structure utilized in Apache ShardingSphere, a closer examination of the cluster mode of ShardingSphere-Proxy can be beneficial. The metadata structure in ZooKeeper adopts a three-layer hierarchy, with the first layer being the governance_ds. This layer encompasses critical components such as metadata information, built-in metadata database, and simulated MySQL database.
governance_ds
--metadata (metadata information)
----sharding_db (logical database name)
------active_version (currently active version)
------versions
--------0
----------data_sources (underlying database information)
----------rules (rules of logical database, such as sharding, encryption, etc.)
------schemas (table and view information)
--------sharding_db
----------tables
------------t_order
------------t_single
----------views
----shardingsphere (built-in metadata database)
------schemas
--------shardingsphere
----------tables
------------sharding_table_statics (sharding statistics table)
------------cluster_information (version information)
----performance_schema (simulated MySQL database)
------schemas
--------performance_schema
----------tables
------------accounts
----information_schema (simulated MySQL database)
------schemas
--------information_schema
----------tables
------------tables
------------schemata
------------columns
------------engines
------------routines
------------parameters
------------views
----mysql
----sys
--sys_data (specific row information of built-in metadata database)
----shardingsphere
------schemas
--------shardingsphere
----------tables
------------sharding_table_statistics
--------------79ff60bc40ab09395bed54cfecd08f94
--------------e832393209c9a4e7e117664c5ff8fc61
------------cluster_information
--------------d387c4f7de791e34d206f7dd59e24c1c
The metadata directory serves as a repository for storing essential rules and data source information, including the currently active metadata version, which is stored under the active_version node. Meanwhile, the versions stored within the metadata directory house different iterations of rules and database connection details. 

On the other hand, the schemas directory is designated for storing comprehensive tables and viewing information from the logical database. ShardingSphere meticulously preserves the decorated table structure information after applying the rules. For instance, in the case of sharding tables, it retrieves the structure from one of the actual tables, replaces the table name, and omits the real encrypted column information in the table structure, allowing users to conveniently operate on the logical database directly. The built-in metadata database, located within the metadata directory, boasts a structure that resembles that of the logical database. However, it is specifically designed to house certain built-in table structures such as sharding_table_statics and cluster_information, which will be elaborated on in subsequent discussions. In addition, the metadata directory also includes other nodes such as performance_schema, information_schema, mysql, sys, and more, which emulate the data dictionary of MySQL. These nodes serve the purpose of supporting various client tools to connect to the proxy, and future plans involve expanding data collection to facilitate queries on these data dictionaries. 

The three-layer metadata structure of ShardingSphere consists of governance_ds, metadata, and a built-in metadata database, is designed to provide compatibility with different database formats. For instance, PostgreSQL has a three-layer structure consisting of instance, database, and schema, whereas MySQL has a two-layer structure of database and table. Therefore, ShardingSphere adds an identical logical schema layer for MySQL to ensure logical uniformity. The meticulously designed three-layer metadata structure of ShardingSphere, encompassing governance_ds, metadata, and a built-in metadata database, has been formulated to ensure seamless compatibility with diverse database formats. For instance, while PostgreSQL follows a three-layer structure comprising instance, database, and schema, MySQL adopts a two-layer structure of database and table. 

To ensure logical uniformity, ShardingSphere introduces an additional logical schema layer for MySQL.Gaining a comprehensive understanding of the metadata structure employed in Apache ShardingSphere is of utmost significance for developers seeking to utilize the platform optimally. By thoroughly examining the metadata structure of ShardingSphere, developers can gain valuable insights into how the platform effectively stores and manages data sources and table structures.

In the preceding section, we examined ShardingSphere's integrated metadata database, encompassing two tables: sharding_table_statistics (a table for collecting sharding information) and cluster_information(a table for storing version information). We also explored the potential of the metadata database to house both internal collection data and user-defined information (yet to be implemented).In this section, we will delve into the inner workings of the built-in metadata database, including its data collection and query implementation mechanisms.

Data Collection

The ShardingSphere's integrated metadata database relies on data collection to aggregate information into memory and synchronizes it with the governance center to ensure consistency across clusters. To illustrate the process of data collection into memory, let's use the sharding_table_statistics table as an example. The ShardingSphereDataCollectorinterface outlines a method for data collection:
Java
 
public interface ShardingSphereDataCollector extends TypedSPI {
    Optional<ShardingSphereTableData> collect(String databaseName, ShardingSphereTable table, Map<String, ShardingSphereDatabase> shardingSphereDatabases) throws SQLException;
}


The aforementioned method is invoked by the ShardingSphereDataCollectorRunnable scheduled task. The current implementation initiates a scheduled task on the Proxy for data collection, utilizing the built-in metadata table to differentiate data collectors for specific data collection tasks. It is worth noting that based on feedback from the community, this approach may evolve into an e-job trigger method for collection in the future. The logic for collecting information is encapsulated in the ShardingStatisticsTableCollectorclass. This class employs the underlying data source and sharding rules to query relevant database information and extract statistical data.

Query Implementation

Upon completion of the data collection process, the ShardingSphereDataScheduleCollector class compares the collected information and the data stored in memory. In the event of any inconsistencies, it triggers an event  EVENTBUSto notify the governance center. Subsequently, upon receiving the event, the governance center updates the information of other nodes and executes memory synchronization accordingly. The code for the event listening class is depicted below:
Java
 
public final class ShardingSphereSchemaDataRegistrySubscriber {
    
    private final ShardingSphereDataPersistService persistService;
    
    private final GlobalLockPersistService lockPersistService;
    
    public ShardingSphereSchemaDataRegistrySubscriber(final ClusterPersistRepository repository, final GlobalLockPersistService globalLockPersistService, final EventBusContext eventBusContext) {
        persistService = new ShardingSphereDataPersistService(repository);
        lockPersistService = globalLockPersistService;
        eventBusContext.register(this);
    }
    
    @Subscribe
    public void update(final ShardingSphereSchemaDataAlteredEvent event) {
        String databaseName = event.getDatabaseName();
        String schemaName = event.getSchemaName();
        GlobalLockDefinition lockDefinition = new GlobalLockDefinition("sys_data_" + event.getDatabaseName() + event.getSchemaName() + event.getTableName());
        if (lockPersistService.tryLock(lockDefinition, 10_000)) {
            try {
                persistService.getTableRowDataPersistService().persist(databaseName, schemaName, event.getTableName(), event...


The Emerging World of Data Security Posture Management

The post-COVID world has seen more organizations adopt remote and hybrid work, allowing employees the flexibility to work from anywhere (WFA). While the move to a remote-hybrid work model for business operations comes with several benefits — like reduced cost and employee retention — it has not been without some challenges. For one, the proliferation of remote-hybrid work also meant that more organizations began migrating their workloads to multi-cloud environments as teams sought to work effectively without interruptions. In fact, one article on Forbes notes that the cloud is the backbone of remote work.

But with more employees working remotely from different parts of the world and sensitive data moving across multi-cloud and hybrid IT architectures, companies are faced with several security risks. From unsecured Wi-Fi networks used by employees to weaker security controls, to cloud misconfigurations, and more, the WFA model has widened the attack surface more than ever before. To put this in a practical perspective, Fortinet’s most recent “Work-From-Anywhere Global Study” shows that over the past 2 to 3 years since COVID-19, “nearly two-thirds of companies have experienced a data breach due to their WFA-employee vulnerabilities.”

Preventing Data Loss With Kafka Listeners in Spring Boot

Data loss is one of the biggest problems developers face when building distributed systems. Whether due to network issues or code bugs, data loss can have serious consequences for enterprises. In this article, we'll look at how to build Kafka listeners with Spring Boot and how to use Kafka's acknowledgment mechanisms to prevent data loss and ensure the reliability of our systems.

Apache Kafka

Apache Kafka is a distributed message platform used to store and deliver messages. Once a message is written to Kafka, it will be kept there according to a retention policy. The consumer groups mechanism is used to read out messages. The offset for each consumer group is used to understand the stage of message processing and to keep track of the progress of each consumer group in reading messages from a partition. It allows each consumer group to independently read messages from a topic and resume reading from where it left off in case of failures or restarts. In a simplified way, this can be represented as follows:
Apache Kafka process

Chris’ Corner: Dithering

Dithering is a vibe:

Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. 

Wikipedia

For an academic PDF, this is pretty approachable.

In the web world, I typically think of it as associated with “indexed colors” images like PNG and GIF can do. For example, if you Save for Web from Adobe Photoshop as a PNG or GIF, you can whack down the colors super low and see some cool dithering.

Here are the three dithering choices my copy of Photoshop has:

“Noise” — 11.1K
“Pattern” — 6.8K
“Dithering” — 7.7K

They are all kinda cool looking if you ask me. More relevant, they made the image smaller in size and require less colors to display. Meaning their aesthetic is like “old-school computing” or “retro video games”.

Acorn, a much more economically friendly image editor, can also dither:

Can you do it right on the web, though? Darn tooting. Well, you can replicate the aesthetic anyway, since you can read images, and we’ve always got tools like <canvas> to play with.

Andrew Stephens made a Web Component that does exactly that. You pass it an image, it reads it and does cool dithering magic, and outputs it onto a canvas for you. He wrote it up in a quick blog post Improved Web Component for Pixel-Accurate Atkinson Dithered Images where he outlines some improvements to this latest version of the component.

I snagged the code and chucked a copy of the web component JavaScript onto our Asset Hosting so I could make a Pen with it. I did have to make a few changes. I had to make the Web Worker inline instead of referencing another file. Then I had to make sure to set img.crossOrigin = "Anonymous"; so I could reference an assets-hosted image as well. You don’t have to do those things if you’re working with all relative paths locally.

This is the original image:

And here’s a Pen where I dither it on-the-fly:

Cool.

This whole vibe matches with another thing I saw recently:

https://end.city/

Refresh the page for a randomly generated busted-up old castle thing. With the random flags and glyphs and icons and stuff I feel like it’s for something specific, but damned if I know what it is.


Speaking of very specific nerdy pursuits, I enjoyed reading Philip Walton’s very custom pursuit of improving LCP (Largest Contentful Paint) in unknown situations. The blog post is Dynamic LCP Priority: Learning from Past Visits.

The overall concept is fairly simple.

  1. One element on the page is responsible. That’s the LCP.
  2. You have no idea what element that is on a dynamic site.
  3. If you did know what it was, you could improve your LCP score by using the fetchpriority attribute on that element (if it’s, say, an image). This can be used to make the browser prioritize loading and rendering that element, improving LCP.
  4. You can’t just use fetchpriority willy nilly, because if you’re wrong, you could actually harm LCP.
  5. You can actually figure out what the LCP element is… after the page has loaded.
  6. That’s too late to be useful, but if you save that information, you could pluck it out of storage and use it to put that fetchpriority on the right element for every different page of your site.

Phew. That’s friggin complicated. Not exactly the lowest-hanging web performance fruit. But it’s cool and nerdy and if you’re chasing the best possible numbers, it can go in the toolbox.

The post Chris’ Corner: Dithering appeared first on CodePen Blog.

How to Add a Currency Converter in WordPress

Do you want to add a currency converter to your blog?

A currency converter allows your website visitors to quickly calculate the exchange rate of different currencies without leaving your website.

In this article, we will show you how to easily add a currency converter in WordPress.

How to add a currency convertor in WordPress

What Type of Websites Need a Currency Converter?

Whether you have an online store, a small business website, or a WordPress blog, as long as you have an international audience and you’re selling something, then you can use a currency converter.

Here are a few examples of websites that may need a currency calculator for WordPress:

  • Ecommerce stores: If you are running an ecommerce store with WordPress and selling products internationally, then a currency converter can help your users quickly calculate costs in their local currency.
  • Travel blogs: If you own a travel blog, then a currency calculator can help your users calculate travel costs in different currencies.
  • Business websites: A business website may also want its users to see the exchange rates of different currencies. Particularly, businesses with a presence in different countries.
  • Finance and banking websites: Websites in the finance and banking industries can add currency calculators for their visitors to calculate conversion rates without leaving their website.
  • Coin and forex exchange sites: There are many websites that blog or deal with crypto-currencies, forex trading, and similar niches. These websites need a currency converter so that their users can quickly calculate conversion rates.

There can be many other WordPress websites that may need a currency converter. That being said, let’s take a look at how to easily add a currency converter in WordPress.

We will show you 2 methods, including a way for WordPress site and WooCommerce store. You can click the links below to jump ahead to your preferred section:

Adding a Currency Converter in WordPress

You easily add a currency converter in WordPress using CBX Currency Converter. It is a free WordPress plugin that calculates and displays up to 117 currencies.

The first thing you need to do is to install and activate the CBX Currency Converter plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, you need to go to Settings » Currency Converter page in your WordPress admin area. From here, you can manage general settings, like choosing a layout for your currency converter and selecting your API source to fetch the exchange rates.

CBX currency converter settings

By default, the plugin will use Exchangerate.host, which doesn’t requires an API key. However, you can click the dropdown menu and choose other sources, like Alphavantage, Openexchangerates, and Currencylayer.

After adding the API key, you can select a layout for the currency converter.

There are 4 layouts to choose from. Using these layouts, you can display a currency calculator, exchange rate list, or both. You can also define the decimal point position.

Layout of currency converter

Besides that, you can further edit the settings for each currency converter layout.

For instance, in the ‘Calculator Default’ tab, you can set the default values for the currency calculator. It allows you to enable currencies, set default options for from and to currencies, and more.

Edit calculator layout settings

After the calculator layout, you can go to the ‘List Default’ tab for currency rate list default settings.

You can select the primary currency and then add a list of other currencies to display in the rate list.

Edit list layout settings

Once you are done with the settings, click the ‘Save Changes’ button. Make sure to perform this step whenever you change any settings in the above tabs.

Displaying the Currency Converter on Your Site

You can easily display the currency converter anywhere on your website using the CBX Currency Converter block.

First, you can create a new page or edit an existing one. Once you’re in the content editor, simply click the ‘+’ button and add the CBX Currency Converter block.

Add the CBX converter to page

Alternatively, you can also display the currency converter in the sidebar of your website.

You can go to Appearance » Widgets from your WordPress dashboard. After that, you can simply add the ‘CBX Currency Converter’ widget block to the sidebar area.

Add CBX converter to sidebar

After adding the widget block, you can edit the title, select a layout, change the decimal points, choose the default currency, and more.

Once you’re done, simply click the ‘Update’ button.

Change the currency converter settings

Simply visit your website to see the currency converter in the sidebar widget or WordPress page.

Your users will be able to enter an amount, select the currency they want to check, and then click the ‘Convert’ button to have the results displayed right there.

Currency convertor widget preview

You can also integrate a currency converter in your WooCommerce or any other WordPress ecommerce site. For this, you will need the Currency Converter Pro plugin.

However, other multi-currency plugins will also get the job done, most of which are free. Let’s look at how you can add a currency converter in WooCommerce.

Adding a Currency Converter in WooCommerce

If you have a WooCommerce store that attracts customers from different parts of the world, then a currency converter can show prices in local currencies and boost conversions.

The easiest way of adding a currency converter in WooCommerce is by using the CURCY plugin. It is a free WooCommerce plugin that is easy to use and offers multi-currency support.

First, you will need to install and activate the CURCY plugin. For more details, please see our guide on how to install a WordPress plugin.

Upon activation, you can head to the Multi Currency page from the WordPress dashboard and view the General settings tab.

CURCY general settings

Here, you can click the ‘Enable’ toggle to activate currency converter options for WooCommerce. Besides that, the plugin also lets you fix the prices.

Next, you can scroll down and add different currencies. Simply click the ‘Add Currency’ button. Do remember that in the free plugin, you can only add 2 currencies at a time.

Add currencies

After that, you can switch to the ‘Location’ tab.

Here, you’ll find options to auto-detect currencies and show a particular currency for visitors from different locations.

Auto detect currencies

Next, you can head to the ‘Design’ tab and edit your currency converter’s appearance.

The plugin lets you choose its position, add a title, change the text color, style, main and background color, and much more.

Change the design of currency converter

Once that’s done, you can save your changes.

You can now visit your WooCommerce store to see the currency converter in action.

WooCommerce currency converter preview

We hope this article helped you learn how to add a currency converter in WordPress. You may also want to see our expert pick of the best calculator plugins for your WordPress site, and how to customize your WooCommerce cart page.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Add a Currency Converter in WordPress first appeared on WPBeginner.