<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Valerii Kantor on Medium]]></title>
        <description><![CDATA[Stories by Valerii Kantor on Medium]]></description>
        <link>https://medium.com/@valerykantor?source=rss-c224cff7d428------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1pMlf_T7cTlod6Iy</url>
            <title>Stories by Valerii Kantor on Medium</title>
            <link>https://medium.com/@valerykantor?source=rss-c224cff7d428------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:03:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@valerykantor/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introducing the New Dashboard: See Your Collection Come to Life]]></title>
            <link>https://medium.com/@valerykantor/introducing-the-new-dashboard-see-your-collection-come-to-life-6860fd46ae71?source=rss-c224cff7d428------2</link>
            <guid isPermaLink="false">https://medium.com/p/6860fd46ae71</guid>
            <category><![CDATA[coin-collecting]]></category>
            <category><![CDATA[collecting]]></category>
            <category><![CDATA[coins]]></category>
            <category><![CDATA[numismatic]]></category>
            <category><![CDATA[stamp-collecting]]></category>
            <dc:creator><![CDATA[Valerii Kantor]]></dc:creator>
            <pubDate>Sun, 08 Feb 2026 08:39:20 GMT</pubDate>
            <atom:updated>2026-02-08T08:39:20.800Z</atom:updated>
            <content:encoded><![CDATA[<p>We’re excited to introduce one of the most important updates to your collecting experience — the new Dashboard. Designed to give you a clear, visual overview of your progress, value, and achievements, it turns your collection data into meaningful insights you can explore at a glance.</p><p>If you’d like to explore it, you can try it here: <a href="https://numizmatclub.com/"><strong>numizmatclub.com</strong></a></p><p>Whether you collect coins, stamps, or banknotes, the dashboard helps you understand how your collection grows over time and celebrates the milestones you reach along the way.</p><h3>A Snapshot of Your Collection</h3><p>The new dashboard is built to answer the most important questions collectors have:</p><ul><li>How big is my collection today?</li><li>Is it growing?</li><li>What is it worth?</li><li>What have I achieved so far?</li></ul><p>Instead of digging through lists, you now get a clean, structured overview the moment you log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUWE1SXwap5IA-bmvnHpGA.png" /><figcaption>Dashboard</figcaption></figure><h3>Collection Statistics at a Glance</h3><p>At the top of the dashboard, you’ll find your collection statistics. These numbers give you an instant understanding of your progress and activity.</p><p>You can quickly see:</p><ul><li>Total number of items in your collection</li><li>Growth over time</li><li>Distribution across categories</li><li>Highlights such as your most collected country or type</li></ul><p>These statistics help you track your collecting journey and stay motivated as your collection expands.</p><h3>Collection Value Chart</h3><p>One of the most powerful features is the collection value chart. This visual timeline shows how the estimated value of your collection changes over time.</p><p>With this chart, you can:</p><ul><li>Track long-term growth</li><li>Spot trends in your collecting habits</li><li>See the impact of new additions</li><li>Better understand the overall worth of your collection</li></ul><p>Watching the line move upward as you add new items brings a whole new level of satisfaction to collecting.</p><p>The last 7 days collection value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BoBADBj8NO5OCxt0-dPLAg.png" /><figcaption>Collection value for the last 7 days</figcaption></figure><p>The last 14 days collection value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yrWvD6scOZE-GcnzgfTwBw.png" /><figcaption>Collection value for the last 14 days</figcaption></figure><h3>Celebrate Progress with Badges</h3><p>Collecting is about more than just numbers — it’s also about achievements. That’s why the dashboard now includes a dedicated section for user badges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KEaMiZOrm9hA0fQCzL17qw.png" /><figcaption>Earn a new badge</figcaption></figure><p>Badges are earned as you reach important milestones, such as:</p><ul><li>Growing your collection</li><li>Collecting items across multiple categories</li><li>Staying active and consistent</li></ul><p>Each badge represents a moment of progress and dedication. As your collection evolves, your badge collection grows with it.</p><h3>Built to Motivate Collectors</h3><p>The dashboard isn’t just a summary — it’s a source of motivation.</p><p>By combining:</p><ul><li>Clear statistics</li><li>Visual value tracking</li><li>Achievement badges</li></ul><p>…it helps you stay engaged and inspired to keep building your collection.</p><p>Even small additions start to feel meaningful when you can see how they contribute to your overall progress.</p><h3>What’s Next?</h3><p>This is just the beginning. The dashboard will continue to evolve with more insights, smarter analytics, and new ways to understand and showcase your collection.</p><p>If you haven’t explored it yet, <a href="https://numizmatclub.com/">log in</a> and take a look. You might be surprised by how far your collection has already come.</p><p>Ready to see your collection in a whole new way?</p><p>Create your free account and explore your personal dashboard: <a href="https://numizmatclub.com/">numizmatclub.com</a></p><p>Start tracking your collection, watch its value grow, and earn your first badges today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6860fd46ae71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encoding Floating-Point Numbers in binary format]]></title>
            <link>https://levelup.gitconnected.com/encoding-floating-point-numbers-in-binary-format-5fb057214dbe?source=rss-c224cff7d428------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fb057214dbe</guid>
            <category><![CDATA[ieee754]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[floating-points]]></category>
            <category><![CDATA[encoding]]></category>
            <dc:creator><![CDATA[Valerii Kantor]]></dc:creator>
            <pubDate>Mon, 03 Jun 2024 15:56:18 GMT</pubDate>
            <atom:updated>2024-06-03T15:56:18.015Z</atom:updated>
            <content:encoded><![CDATA[<p>The presentation of integer numbers in computers is pretty straightforward but what about real numbers? How a real number is encoded in computer memory? The answer is the IEEE-754 standard which describes how a computer handles floating-point numbers. The standard defines a format that is used to represent a finite subset of real numbers in binary format. According to the standard, a real number can be encoded in lengths of 32, 64, and 128 bits.</p><p>IEEE-754 says a number can be broken down into three components:</p><p><strong>Sign -</strong> A 1-bit value represents a number sign</p><p><strong>Exponent -</strong> w-bits value of the biased exponent represents both positive and negative exponent values.</p><p><strong>Mantissa -</strong> t-bits value of a normalized scientific form of a floating-point number. (It also can be called as a fraction)</p><figure><img alt="Binary floating-point format" src="https://cdn-images-1.medium.com/max/1024/1*3eQITpeCkMpd_WvYubPvbw.png" /><figcaption>Binary floating-point format</figcaption></figure><p>The standard defines three binary formats:</p><p>32-bits — Single precision</p><p>64-bits — Double precision</p><p>128-bits — Quadruple precision</p><figure><img alt="Parameters defining basic floating-point numbers" src="https://cdn-images-1.medium.com/max/1024/1*8Ha0ryVkGACW6AdiQgomKA.png" /><figcaption>Parameters defining basic floating-point numbers</figcaption></figure><p>Let’s go through an example of the conversion of a real number to a single precision binary format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xfhXIU1blsMI-pblclYEGw.png" /><figcaption>Single precision format</figcaption></figure><p>The algorithm for converting a floating-point number to a binary format is straightforward.</p><ol><li>Divide the number into two parts: integer and fractional parts</li><li>Convert integer part to binary (in base-2)</li><li>Convert the fractional part to binary (in base-2)</li><li>Join both the integer part and the fractional part with a binary point.</li><li>Normalize the binary representation from step 4 into the scientific form</li><li>Convert the result from the previous step to IEEE-754 format.<br>1. Adjust the exponent in biased notation and convert the adjusted exponent to binary format.<br>2. Normalize mantissa by removing the leftmost bit and adjust the length to 23 bits if necessary</li><li>Determine the sign of the number. “1” if the number is positive and “0” for negative.</li><li>Combine all three parts (the sign, the adjusted exponent, normalized mantissa).</li></ol><p>So, Let’s assume we would like to convert 123.125 to binary format.</p><p>Split the number into two parts: 123 and 0.125.</p><p>Convert the integer part to binary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*BzO9x4eBtk1dXwcpxFy4ag.png" /></figure><p>Convert the fractional part to binary. To get it, you need to multiply the fraction part repeatedly by 2. This process repeats until we get the fraction part equals zero or gets iteration counter exceeds the limit of the mantissa size (for a 32-bit floating-point number it is 23).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*0fu_VCfRHJMoo6iw99EfJw.png" /></figure><p>At this point, there are two components in binary to join with the binary point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*sfrDPG2Srkh2j_sqpLExFg.png" /></figure><p>The value above has to be normalized in scientific form by shifting the decimal point 6 positions to the left, so only one non-zero digit remains to the left of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*T0OYpa8dArHttecX8nVoRA.png" /></figure><p>So, now, 6 is the value of the exponent which must be adjusted to biased notation by adding 127 (for double precision value it&#39;s 1023).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*V8oME6tvV_1tDSS0yQUgOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*_H5Mz4UsQDsxYFZA_P-vjg.png" /></figure><p>Normalize the mantissa. At this step, the algorithm involves removing the leading (the leftmost) bit and adjusting the length of the mantissa to 23-bits by either trimming excess bits from the right or adding zero bits to the right if it is shorter than 23-bits. In our case, after removing the leading bit the mantissa is 9-bits length, so it needs to add 14 zeros to the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtWhHpmjVcriDILMPb8pQA.png" /></figure><p>The last step is to combine all three parts (sign, exponent, and mantissa) to get the binary-encoded floating-point number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Qr6wyd6YkitRqubEao3gg.png" /><figcaption>Binary encoded floating-point number</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*7er2_W5zC2y2uaunzaaa_g.png" /><figcaption>Floating-point number in HEX</figcaption></figure><p>Please, check out the Java implementation of the algorithm on GitHub: <a href="https://github.com/golgotha/floating-point-encoder">https://github.com/golgotha/floating-point-encoder</a></p><p>I hope you like it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fb057214dbe" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/encoding-floating-point-numbers-in-binary-format-5fb057214dbe">Encoding Floating-Point Numbers in binary format</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Synchronous and Asynchronous microservice communication in Spring Framework]]></title>
            <link>https://levelup.gitconnected.com/synchronous-and-asynchrounous-microservice-communication-in-spring-framework-abbf4c0d24ad?source=rss-c224cff7d428------2</link>
            <guid isPermaLink="false">https://medium.com/p/abbf4c0d24ad</guid>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[rabbitmq]]></category>
            <dc:creator><![CDATA[Valerii Kantor]]></dc:creator>
            <pubDate>Sun, 18 Jun 2023 22:21:10 GMT</pubDate>
            <atom:updated>2023-06-30T12:44:43.229Z</atom:updated>
            <content:encoded><![CDATA[<p>Nowadays plenty of Java applications have microservices architecture using Spring Boot. Spring Boot is a powerful tool to build applications based on Spring Framework. In a real application, the services communicate with each other under different protocols but all those protocols are divided into two types: synchronous and asynchronous. Let’s look through them.</p><h3><strong>Synchronous</strong></h3><p>Synchronous service communication is the most popular and straightforward solution to communicate between services. The most common and well know protocol is HTTP. HTTP protocol is the heart of technologies like REST, GraphQL but there are alternatives such as gRPC, Apache Thrift, Apache Avro and so on.</p><p>When a service makes a request to another service using a synchronous request the execution of the service which initiates the request stops while it gets a response from the requested service or it fails by timeout if the service that was requested does not respond.</p><p>Synchronous communication has pros and cons. The main disadvantage of synchronous communication is blocking context while a request is executing but on the other hand, the execution process is straightforward.</p><p>Spring Framework has a few ways for synchronous communiration If your services uses REST API for each other communication:</p><ul><li>REST Template</li><li>WebClient</li><li>HTTP Interface Client (since Spring 6)</li><li>Feign Client (If you using Spring Cloud OpenFeign project)</li></ul><h4><strong>REST Template</strong></h4><p>RestTemplate was introduced in Spring 3. The class has overload methods for different HTTP requests, such as GET, POST, PUT and DELETE. By default it uses HTTP but it is possible to configure to use HTTPS (e.g. use Apache HttpComponents and define SSLContext).</p><pre>@Component<br>public class RestTemplateCatFactsClient {<br><br>    private final RestTemplate restTemplate;<br><br>    public RestTemplateCatFactsClient(RestTemplate restTemplate) {<br>        this.restTemplate = restTemplate;<br>    }<br><br>    public List&lt;Fact&gt; getFacts() {<br>        ResponseEntity&lt;List&lt;Fact&gt;&gt; exchange = restTemplate.exchange(<br>                &quot;https://cat-fact.herokuapp.com/facts&quot;,<br>                HttpMethod.GET,<br>                null,<br>                new ParameterizedTypeReference&lt;&gt;() {});<br><br>        return exchange.getBody();<br>    }<br>}</pre><h4>WebClient</h4><p>WebClient was introduced in Spring 5 as part of the Reactive module as reactive, non-blocking solution that works over HTTP. WebClient works as a non-blocking and blocking client. To use WebClient in the non-blocking context you need to invoke <strong>subscribe</strong> method. If you’d like to use in a blocking context you have to call the <strong>block</strong> method.</p><pre>@Component<br>public class WebClientCatFactsClient {<br><br>    private final WebClient client;<br><br>    public WebClientCatFactsClient(@Value(&quot;${api.baseurl}&quot;) String baseUrl) {<br>        this.client = WebClient.builder().baseUrl(baseUrl).build();<br>    }<br><br>    public Flux&lt;Fact&gt; getFacts() {<br>        return client.get()<br>                .uri(&quot;/facts&quot;)<br>                .retrieve()<br>                .bodyToFlux(Fact.class);<br>    }<br>}</pre><h4>HTTP Interface Client</h4><p>HTTP Interface Client introduced in Spring 6. The HTTP Interface Client enables to definition a declarative way for HTTP services using Java interfaces. Under the hood, Spring generates a proxy class that implements the interface and performs exchanges.</p><p>Define an interface:</p><pre>public interface CatFactsClient {<br><br>    @GetExchange(value = &quot;/facts&quot;)<br>    List&lt;Fact&gt; getFacts();<br>}</pre><p>Definde CatFactsClient bean in configuration</p><pre>@Configuration<br>public class CatFactsClientConfig {<br><br>    @Bean<br>    public CatFactsClient catFactsClient() {<br>        WebClient client = WebClient.builder().baseUrl(&quot;https://cat-fact.herokuapp.com&quot;).build();<br>        HttpServiceProxyFactory factory = HttpServiceProxyFactory.builder(WebClientAdapter.forClient(client)).build();<br>        return factory.createClient(CatFactsClient.class);<br>    }<br>}</pre><p>Now you can use CatFactsClient in you code like:</p><pre>@Service<br>public class MyService {<br><br>  @Autowired<br>  private CatFactsClient catFactsClient;<br><br>  public List&lt;Fact&gt; fetchCatFacts() {<br>    return catFactsClient.getFacts();<br>  }<br><br>}</pre><h4>Feign Client</h4><p>Feign Client is a declarative REST client that is a part of Spring Cloud. To use the client you need to create an interface and annotate it. The Feign is pluggable which means it supports Spring MVC annotations and JAX-RS annotations.</p><p>Firstly, you need to enable Feign Client auto-configuration by adding <strong>@EnableFeignClients</strong> annotation in your application configuration.</p><pre>@EnableFeignClients<br>public class AppConfig {<br><br>}</pre><p>Then, you need to create an interface and annotate it with <strong>@FeignClient </strong>annotation.</p><pre>@FeignClient(name = &quot;cats-facts&quot;, url = &quot;https://cat-fact.herokuapp.com&quot;)<br>public interface FeignCatFactsClient {<br><br>    @GetMapping(value = &quot;/facts&quot;)<br>    List&lt;Fact&gt; getFacts();<br><br>}</pre><p>Now, it is ready to use by injecting FeignCatFactsClient into you service.</p><h3><strong>Asynchronous</strong></h3><p>Asynchronous communication is alternative to synchronous. This communication protocol doesn’t block executing context until to get the response from another service. In other words, when a service sends an asynchronous request to another service it doesn’t need to wait for receiving the service’s reply. The most popular solutions are message brokers like RabbitMQ, Kafka, ActiveMQ, Amazon Kenesis or even Redis is possible to use as a message broker.</p><h4>Messaging with RabbitMQ</h4><p>Spring has anAMQP component that allows publishing and subscribes to messages as a POJO.</p><h4>Publish a message</h4><p>Message publishing in the Spring framework is easy. There is <strong>RabbitTemplate</strong> which provides multiple methods to send a message and encapsulate all logic inside. Basically, RabbitTemplate provides two types of methods to send a message. The first method is called <strong>send. </strong>This method sends a message as binary data using org.springframework.amqp.core.Message wrapper. The second method is <strong>convertAndSend </strong>which sends a message as a POJO. Actually <strong>convertAndSend </strong>executes <strong>send</strong> method at the end but before it converts POJO to an array of bytes using converters.</p><p>Let’s create a publisher to publish a message every second</p><pre>public class Publisher {<br>    private RabbitTemplate rabbitTemplate;<br><br>    public Publisher(RabbitTemplate rabbitTemplate) {<br>        this.rabbitTemplate = rabbitTemplate;<br>    }<br><br>    public void publish(String value) {<br>        rabbitTemplate.convertAndSend(AppConfig.EXCHANGE, &quot;foo.bar&quot;, value);<br>    }<br><br>    @Scheduled(fixedRate = 1000)<br>    public void sayHello() {<br>        publish(&quot;Hello&quot;);<br>    }<br>}</pre><h4>Receiving a message</h4><p>Spring AMQP provides <strong>SimpleMessageListenerContainer</strong> to receive messages from RabbitMQ. The containers accept MessageListenerAdapter which is an adapter between your receiver implementation and SimpleMessageListenerContainer.</p><p>Create a class to consume an incoming message</p><pre>@Log4j2<br>@Component<br>public class Receiver {<br><br>    public void receive(String message) {<br>        log.info(&quot;Received: {}&quot;, message);<br>    }<br>}</pre><p>Define a <strong>SimpleMessageLinsterContainer</strong> and <strong>MessageListenerAdaper</strong> as beans in your configuration:</p><pre>@Bean<br>public SimpleMessageListenerContainer container(ConnectionFactory connectionFactory,<br>                                                MessageListenerAdapter listenerAdapter) {<br>  SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();<br>  container.setConnectionFactory(connectionFactory);<br>  container.setQueueNames(QUEUE_NAME);<br>  container.setMessageListener(listenerAdapter);<br>  return container;<br>}<br><br>@Bean<br>public MessageListenerAdapter listenerAdapter(Receiver receiver) {<br>  return new MessageListenerAdapter(receiver, &quot;receive&quot;);<br>}</pre><p><strong>MessageListernerAdapter</strong> takes two arguments in the constructor. The first is a consumer that handles a message and the second is the name of the method that handles a message.</p><p>This example is related to RabbitMQ but if you are not using RabbitMQ the process in most cases the similar except for some vendor-specific configuration.</p><p>Check out github example: <a href="https://github.com/golgotha/spring-communication-clients">https://github.com/golgotha/spring-communication-clients</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abbf4c0d24ad" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/synchronous-and-asynchrounous-microservice-communication-in-spring-framework-abbf4c0d24ad">Synchronous and Asynchronous microservice communication in Spring Framework</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Docker container eating disk space?]]></title>
            <link>https://levelup.gitconnected.com/why-docker-container-eating-disk-space-fdbed68bc351?source=rss-c224cff7d428------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdbed68bc351</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-image]]></category>
            <dc:creator><![CDATA[Valerii Kantor]]></dc:creator>
            <pubDate>Sun, 04 Jun 2023 19:12:39 GMT</pubDate>
            <atom:updated>2023-06-04T19:12:39.390Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o1DdCfTDuliz4ddv" /><figcaption>Photo by <a href="https://unsplash.com/@carrier_lost?utm_source=medium&amp;utm_medium=referral">Ian Taylor</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Docker is an excellent platform to run modern applications. It allows developers to create isolated environments to launch their applications. Nevertheless sometimes you might encounter issues with your application running in Docker. I am not an exception.</p><p>We have a Java application that launched as a docker container and deployed to Elastic Beanstalk on AWS. After a few weeks, I noticed there is no disk space on an EC2 instance. I’ve started an investigation of the issue and realized that the Docker directory <strong><em>/var/lib/docker/containers</em></strong> takes up a lot of disk space. When I’ve deepened into directories I found out there is a file like: <strong>8b205c56bbd7251a8c15a1a8f24932894b291a91cdba1d2af6b7485f9f9349e3-json.log</strong>. The file size was around 4.5 GB. The content of the file was a JSON.</p><p>Log file content:</p><pre>/var/lib/docker/containers/34c14ffc63b42c38b97189e1800639cea8444711765ba52617f8da4c56888760 # cat 34c14ffc63b42c38b97189e1800639cea8444711765ba52617f8da4c56888760-json.log<br>{&quot;log&quot;:&quot;\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.923535008Z&quot;}<br>{&quot;log&quot;:&quot;  .   ____          _            __ _ _\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.923574932Z&quot;}<br>{&quot;log&quot;:&quot; /\\\\ / ___&#39;_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.923580256Z&quot;}<br>{&quot;log&quot;:&quot;( ( )\\___ | &#39;_ | &#39;_| | &#39;_ \\/ _` | \\ \\ \\ \\\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.923942028Z&quot;}<br>{&quot;log&quot;:&quot; \\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.924105421Z&quot;}<br>{&quot;log&quot;:&quot;  &#39;  |____| .__|_| |_|_| |_\\__, | / / / /\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.92438507Z&quot;}<br>{&quot;log&quot;:&quot; =========|_|==============|___/=/_/_/_/\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.924653121Z&quot;}<br>{&quot;log&quot;:&quot;\u001b[32m :: Spring Boot :: \u001b[39m              \u001b[2m (v2.7.7)\u001b[0;39m\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.926429833Z&quot;}<br>{&quot;log&quot;:&quot;\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.92644924Z&quot;}<br>{&quot;log&quot;:&quot;\u001b[2m2023-01-19 05:45:19.993\u001b[0;39m \u001b[32m INFO\u001b[0;39m \u001b[35m1\u001b[0;39m \u001b[2m---\u001b[0;39m \u001b[2m[           main]\u001b[0;39m \u001b[36mc.e.dockerlog.DockerLogApplication      \u001b[0;39m \u001b[2m:\u001b[0;39m Starting DockerLogApplication using Java 17.0.1 on 34c14ffc63b4 with PID 1 (/app/app.jar started by root in /)\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.996190497Z&quot;}<br>{&quot;log&quot;:&quot;\u001b[2m2023-01-19 05:45:19.997\u001b[0;39m \u001b[32m INFO\u001b[0;39m \u001b[35m1\u001b[0;39m \u001b[2m---\u001b[0;39m \u001b[2m[           main]\u001b[0;39m \u001b[36mc.e.dockerlog.DockerLogApplication      \u001b[0;39m \u001b[2m:\u001b[0;39m No active profile set, falling back to 1 default profile: \&quot;default\&quot;\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:19.997534117Z&quot;}<br>{&quot;log&quot;:&quot;\u001b[2m2023-01-19 05:45:21.720\u001b[0;39m \u001b[32m INFO\u001b[0;39m \u001b[35m1\u001b[0;39m \u001b[2m---\u001b[0;39m \u001b[2m[           main]\u001b[0;39m \u001b[36mo.s.b.web.embedded.netty.NettyWebServer \u001b[0;39m \u001b[2m:\u001b[0;39m Netty started on port 8080\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:21.720759348Z&quot;}<br>{&quot;log&quot;:&quot;\u001b[2m2023-01-19 05:45:21.731\u001b[0;39m \u001b[32m INFO\u001b[0;39m \u001b[35m1\u001b[0;39m \u001b[2m---\u001b[0;39m \u001b[2m[           main]\u001b[0;39m \u001b[36mc.e.dockerlog.DockerLogApplication      \u001b[0;39m \u001b[2m:\u001b[0;39m Started DockerLogApplication in 2.206 seconds (JVM running for 2.682)\r\n&quot;,&quot;stream&quot;:&quot;stdout&quot;,&quot;time&quot;:&quot;2023-01-19T05:45:21.732405272Z&quot;}</pre><p>The application log in the console output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0fcnyd5CcXoa0zJkJb8sA.png" /><figcaption>Console output stream</figcaption></figure><p>The log file created by Docker contains the same output but stored in JSON format. But, why does this file become so big?</p><p><strong>Docker logging system</strong></p><p>Docker includes multiple logging strategies to help you to get information from running containers. These strategies are called logging drivers. By default, Docker uses the “<strong>json-file”</strong> logging driver. If we check the documentation we find out that the “<strong>json-file”</strong> driver works without log-rotation as default to remain backward compatible with older versions and for cases when Docker is used as a runtime for Kubernetes.</p><p>The Docker team suggests using the “<strong>local</strong>” logging driver to prevent disk-exhaustion that by default preserves 100MB of log messages per container but you also can configure the “<strong>json-file</strong>” driver with log-rotation as well.</p><p>The log driver configuration supports a batch of options. Some of the options have a default values. If we look at <strong>max-size </strong>option the documentation says:</p><blockquote>The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g). Defaults to -1 (unlimited).</blockquote><p>The value -1 is the answer to why the log file is oversized over time. It is because Docker doesn’t control the size of the log by default.</p><p>We can fix the issue if we restrict the size of the log file by setting max-size equals 10m. There is a second option <strong>max-file </strong>allows to restrict the maximum numbers of log files. The oldest files will be removed if the logger creates an excess file. Every time when the current log file exceeds the value defined in <strong>max-size </strong>it leads to create a new logs file and add to the name current file with a suffix. The suffix is a number index. Note, <strong>max-file </strong>option is effective only when <strong>max-size</strong> is set too.</p><p>We can run the container:</p><pre>docker run -it -log-opt max-size=10m -log-opt max-file=5 IMAGE[:TAG]</pre><p>The container will have a maximum of 5 files no larger than 10 megabytes each.</p><p>If you run containers using docker-compose just add the following snippet into a service definition:</p><pre>logging: <br>  options:<br>    max-size: &quot;10m&quot;<br>    max-file: &quot;5&quot;</pre><p><strong>Conclusion</strong></p><p>When you are running a Docker container you have to read the documentation carefully to understand how some product component works by default. In most cases, the default configuration is enough for development but not for production.</p><p>I hope you like it!</p><h3>Level Up Coding</h3><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in the <a href="https://levelup.gitconnected.com/?utm_source=pub&amp;utm_medium=post">Level Up Coding publication</a></li><li>💰 Free coding interview course ⇒ <a href="https://skilled.dev/?utm_source=luc&amp;utm_medium=article">View Course</a></li><li>🔔 Follow us: <a href="https://twitter.com/gitconnected">Twitter</a> | <a href="https://www.linkedin.com/company/gitconnected">LinkedIn</a> | <a href="https://newsletter.levelup.dev/">Newsletter</a></li></ul><p>🚀👉 <a href="https://jobs.levelup.dev/talent/welcome?referral=true"><strong>Join the Level Up talent collective and find an amazing job</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdbed68bc351" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/why-docker-container-eating-disk-space-fdbed68bc351">Why Docker container eating disk space?</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to detect even or odd value]]></title>
            <link>https://levelup.gitconnected.com/how-to-detect-even-or-odd-value-e6d5a31deccb?source=rss-c224cff7d428------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6d5a31deccb</guid>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Valerii Kantor]]></dc:creator>
            <pubDate>Thu, 11 May 2023 04:32:12 GMT</pubDate>
            <atom:updated>2023-05-11T04:32:12.256Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jIyhLAmFSe6vWiDT" /><figcaption>Photo by <a href="https://unsplash.com/@d_kah?utm_source=medium&amp;utm_medium=referral">d kah</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I think each developer who just started programming and algorithms learning faced situations when it is necessary to detect if an integer value is even or odd. Which way do you usually determine this? The answer is in math. To solve the issue you need to divide an integer value by 2 and take a remainder. If the remainder value is 0, it means the source value is even, otherwise the source value is odd.</p><p>Usually, we use an operation called modulo or remainder operator. There is an operator ‘%’ in Java and C++ or “mod” in other old school languages like Basic and Pascal. In my opinion, “<em>a % n”</em> expression is widely known.</p><p>Java example:</p><pre>public boolean isEven(int value) {<br>  return value % 2 == 0;<br>}</pre><p>Calculation of remainder is a pretty expensive operation because it requires performing division operation in CPU. Modern compilers and CPU can optimize modulo if we calculate remainder against of 2ᵏ.</p><p>x % 2ᵏ == x &amp; (2ᵏ — 1)</p><p>If we look through the formula carefully, we can see that we have another way to detect even or odd value. ²¹ is 2. Hence, we can conclude that we just need to perform the following bitwise operation x &amp; 1.</p><p>Let’s look at representation of numbers 0, 1, 2, 3, 4 in binary system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*pqItcP9BMeah5yEB9FpMXg.png" /><figcaption>binary representation</figcaption></figure><p>As you can see, a low bit in each number follows a pattern. It is either 0 or 1. If a value is even, the low bit is 0. Otherwise if a value is odd, the low bit is 1.</p><p>It means we can use this alternative method to detect if a value is even or odd:</p><pre>public boolean isEven(int value) {<br>  return value &amp; 1 == 0;<br>}</pre><p>I hope you like it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6d5a31deccb" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-to-detect-even-or-odd-value-e6d5a31deccb">How to detect even or odd value</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to implement FTP-Server in Spring Boot application. Authentication (Part 2 )]]></title>
            <link>https://medium.com/@valerykantor/how-to-implement-ftp-server-in-spring-boot-application-authentication-part-2-2be3c8c901b8?source=rss-c224cff7d428------2</link>
            <guid isPermaLink="false">https://medium.com/p/2be3c8c901b8</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[ftp-server]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Valerii Kantor]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 20:38:37 GMT</pubDate>
            <atom:updated>2023-02-28T22:55:35.016Z</atom:updated>
            <content:encoded><![CDATA[<p>That is the second part of the article about FTP server implementation. If you haven’t read <a href="https://medium.com/@valerykantor/how-to-implement-ftp-server-in-spring-boot-application-67b3362289bd"><strong>part 1</strong></a><strong> </strong>I suggest you to do it before. In this topic, we will look at user authentication on FTP-Server.</p><h3>User authentication</h3><p>A FTP is a service in our architecture that is used by other services. So, one of the key requirements is the authentication of clients which we already have in our system. Apache FtpServer provides an interface <strong>UserManager </strong>that allows managing a user access to FTP-Server<strong>. </strong>The interface lets you implement any solution as a data source for authentication like: database, key-value storage, file, in-memory, etc. We don’t implement all methods from the <strong>UserManager </strong>interface but if you need it for your certain task, you can do it. The main three methods that are interesting for us <strong>getUserByName, doesExist</strong> and <strong>authenticate</strong>. Below you can find a short version of the <strong>UserManager </strong>interface that represents the methods which we are going to implement.</p><pre>public interface UserManager {<br>  <br>  User getUserByName(String username) throws FtpException;<br>  <br>  boolean doesExist(String username) throws FtpException;<br>  <br>  User authenticate(Authentication authentication) throws AuthenticationFailedException;<br>  // The rest part of methods <br>  // ...<br>}</pre><p>Let’s go through these methods.</p><p><strong>getUserByName</strong> is called when a FTP client executes a USER command. USER command performs user authentication by name. In other words, the command checks for user existence. This command is usually followed by the PASS which verifies a password provided in the command. The PASS command executes the second method which is called an <strong>authenticate</strong>. The method performs the final step of user authentication. If authentication is successful the server gives access to its file system. The last method that we implement is called <strong>doesExist </strong>that is executed by SITE DESCUSER command handler. You can familiarize yourself with an implementation of a user authentication:</p><pre>@Service<br>public class TenantUserManager implements UserManager {<br>    @Autowired<br>    private TenantRepository tenantRepository;<br>    @Autowired<br>    private HomeDirectoryResolver homeDirectoryResolver;<br>    @Autowired<br>    private FtpServerProperties serverProperties;<br><br>    @Override<br>    public User getUserByName(String username) throws FtpException {<br>        String homeDirectory;<br>        List&lt;Authority&gt; authorities = new ArrayList&lt;&gt;();<br>        authorities.add(new WritePermission());<br>        if (!isAdmin(username)) {<br>            Tenant tenant = tenantRepository.findByName(username)<br>                    .orElseThrow(() -&gt; new FtpException(format(&quot;User {0} not found&quot;, username)));<br>            homeDirectory = resolveUserHomeDirectory(tenant.getHomeDirectory());<br>            authorities.add(new ConcurrentLoginPermission(0, 0));<br>        } else {<br>            homeDirectory = resolveAdminHomeDirectory();<br>            // allow only one admin connection at the same time<br>            authorities.add(new ConcurrentLoginPermission(1, 0));<br>        }<br>        BaseUser user = new BaseUser();<br>        user.setName(username);<br>        user.setHomeDirectory(homeDirectory);<br>        user.setEnabled(true);<br>        user.setAuthorities(authorities);<br>        return user;<br>    }<br><br>    @Override<br>    public boolean doesExist(String username) throws FtpException {<br>        return tenantRepository.existsByName(username);<br>    }<br><br>    @Override<br>    public User authenticate(Authentication authentication) throws AuthenticationFailedException {<br>        if (authentication instanceof AnonymousAuthentication) {<br>            throw new AuthenticationFailedException(&quot;Anonymous users doesn&#39;t supported&quot;);<br>        }<br>        UsernamePasswordAuthentication usernamePasswordAuthentication = (UsernamePasswordAuthentication) authentication;<br>        var username = usernamePasswordAuthentication.getUsername();<br>        var password = usernamePasswordAuthentication.getPassword();<br>        try {<br>            if (isAdmin(username)) {<br>                verifyAdminPassword(password);<br>            } else {<br>                var tenant = tenantRepository.findByName(username)<br>                        .orElseThrow(() -&gt; new AuthenticationFailedException(&quot;Invalid user credentials&quot;));<br>                if (!tenant.getPassword().equals(password)) {<br>                    throw new AuthenticationFailedException(&quot;Invalid user credentials&quot;);<br>                }<br>            }<br>            return getUserByName(username);<br>        } catch (FtpException e) {<br>            throw new AuthenticationFailedException(e);<br>        }<br>    }<br><br>    @Override<br>    public String getAdminName() throws FtpException {<br>        return serverProperties.getAdmin().getUsername();<br>    }<br><br>    @Override<br>    public boolean isAdmin(String username) throws FtpException {<br>        return serverProperties.getAdmin().getUsername().equals(username);<br>    }<br><br>    public String resolveAdminHomeDirectory() {<br>        return homeDirectoryResolver.resolve() + &quot;/&quot;;<br>    }<br><br>    private void verifyAdminPassword(String password) throws AuthenticationFailedException {<br>        if (!serverProperties.getAdmin().getPassword().equals(password)) {<br>            throw new AuthenticationFailedException(&quot;Invalid user credentials&quot;);<br>        }<br>    }<br>    <br>    private String resolveUserHomeDirectory(String homeDirectory) {<br>        return homeDirectoryResolver.resolve() + &quot;/&quot; + homeDirectory;<br>    }<br>}</pre><p>I’ve mentioned before the <strong>getUserByName </strong>method<strong> </strong>that<strong> </strong>is used by the USER command. This command performs basic authentication, like checking the username and set permissions for a particular user depending on the user role. My example demonstrates the following behavior: if a user is an admin the method sets <strong>maxConcurrentLogins</strong> equal to 1 in ConcurentLoginPermission class. It means only one session for the admin can exist at the same time.</p><p><strong>TenantRepository</strong> provides access to user data in RDBS. Since <strong>TenantRepository</strong> is an interface you can use any storage as a data source.</p><p><strong>HomeDirectoryResolver</strong> interface is resolves a user home directory path. Implementation of this interface will be described in the next article.</p><p>The first action that we take using the <strong>authenticate</strong> method is checking for the authentication of an anonymous user. If a user is anonymous our server decline authentication.</p><pre>if (authentication instanceof AnonymousAuthentication) {<br>  throw new AuthenticationFailedException(&quot;Anonymous users doesn&#39;t supported&quot;);<br>}</pre><p>Then we just check if it is a user admin or regular user and set permissions depending on user status.</p><p>That was a basic custom user authentication configuration for Apache FtpServer.</p><p>I hope you like it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2be3c8c901b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to implement FTP-Server in Spring Boot application]]></title>
            <link>https://medium.com/@valerykantor/how-to-implement-ftp-server-in-spring-boot-application-67b3362289bd?source=rss-c224cff7d428------2</link>
            <guid isPermaLink="false">https://medium.com/p/67b3362289bd</guid>
            <category><![CDATA[ftp-server]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Valerii Kantor]]></dc:creator>
            <pubDate>Wed, 08 Feb 2023 06:31:36 GMT</pubDate>
            <atom:updated>2023-02-08T06:31:36.213Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to implement FTP-Server in Spring Boot application (Part 1)</h3><p>I would like to share my experience of creating an FTP server. Before we start, I would like to explain why we need to create an FTP server instead of using an existing solution. Let me guess that you actually could ask me “Why didn’t you use one of the existing solutions?”</p><p>Our company uses a batch of services from a third-party product. The services provide data from different ways like MQ, REST API, Socket and FTP. The third-party provider produced the data provided through the FTP server. Each time when the provider has a new portion of data it is uploaded to the FTP server maintained by the provider.</p><p>One day a product owner came to me with a question: Can we run our own FTP server? The third-party provider stopped their FTP servers but they can continue to publish data to the FTP server provided by us. The first thought that came into my brain was “We can use AWS Transfer Family”. It was a good idea but there were some restrictions. The first one is the price. I’ve checked the price and it appeared to be pretty expensive for our business. The second restriction, we need to allow only access to FTP for already existing users managed on our side.</p><p><strong>Requirements</strong></p><ul><li>User management.</li><li>Forbidden access to anonymous users.</li><li>Using S3 as data storage.</li><li>Fault Tolerance.</li></ul><p>After some research, I found out that we can use Apache FtpServer as an FTP server implementation. Apache FtpServer can be launched either as a stand-alone or an embedded application. Another nice feature of Apache FtpServer is an ability to be extendable. It means we can easily use it as a data storage local file system, S3 or even switch to another data storage system like Azure Blob Storage. We decided to use Apache Commons VFS as a file system provider for FTP. Apache VFS provides a single API for accessing various different file systems. It presents a uniform view of the files from various different sources, such as the files on a local disk, on an HTTP server, or inside a Zip archive. What does it mean? We can use a single API as a facade to be abstract from data location.</p><h3>Apache FtpServer as Spring Boot application</h3><p>Spring Framework is the best implementation of the Inversion of Control and Dependency Injection pattern for the Java platform. I will not describe what is the Inversion of Control and Dependency Injection. You can read about these concepts here: <a href="https://en.wikipedia.org/wiki/Inversion_of_control">https://en.wikipedia.org/wiki/Inversion_of_control</a>, <a href="https://en.wikipedia.org/wiki/Dependency_injection">https://en.wikipedia.org/wiki/Dependency_injection</a></p><p>Plenty of companies choose Spring as a framework for the development of their projects. Our company is not an exception. Most of the services are written in Java. That’s why we run Apache FtpServer as a Spring Boot application.</p><p>Firstly, we need to create a FtpServerBean that will start and stop the server when the Spring context is up or down:</p><pre>public class FtpServerBean implements InitializingBean, DisposableBean {<br><br>    private final FtpServer server;<br><br>    public FtpServerBean(FtpServer server) {<br>        this.server = server;<br>    }<br><br>    @Override<br>    public void afterPropertiesSet() throws Exception {<br>        this.server.start();<br>    }<br><br>    @Override<br>    public void destroy() throws Exception {<br>        this.server.stop();<br>    }<br>}</pre><p>The FTP server starts when BeanFactory set all properties for FtpServerBean and stops the server in order to release allocated resources after the Spring application’s shutdown.</p><p>The second step is to define all beans in a configuration together.</p><pre>@Configuration<br>@EnableConfigurationProperties(FtpServerProperties.class)<br>public class FtpServerConfiguration {<br><br>    @Bean<br>    public FtpServerBean ftpServerInstance(Listener listener,<br>                                           TenantUserManager userManager,<br>                                           FileSystemFactory fileSystemFactory,<br>                                           ConnectionConfigFactory connectionConfigFactory) {<br>        FtpServerFactory ftpServerFactory = new FtpServerFactory();<br>        ftpServerFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());<br>        ftpServerFactory.setFtplets(Collections.singletonMap(&quot;custom&quot;, new CustomFtplet()));<br>        ftpServerFactory.setListeners(Collections.singletonMap(&quot;default&quot;, listener));<br>        ftpServerFactory.setUserManager(userManager);<br>        ftpServerFactory.setFileSystem(fileSystemFactory);<br>        return new FtpServerBean(ftpServerFactory.createServer());<br>    }<br><br>    @Bean<br>    public ConnectionConfigFactoryBean connectionConfigFactory(FtpServerProperties properties) {<br>        ConnectionConfigFactoryBean connectionConfigFactoryBean = new ConnectionConfigFactoryBean();<br>        connectionConfigFactoryBean.setMaxLogins(properties.getMaxLogins());<br>        return connectionConfigFactoryBean;<br>    }<br><br>    @Bean<br>    public Listener listener(FtpServerProperties properties,<br>                             DataConnectionConfigurationFactory connectionConfigurationFactory) throws IOException {<br>        ListenerFactory factory = new ListenerFactory();<br>        factory.setDataConnectionConfiguration(connectionConfigurationFactory.createDataConnectionConfiguration());<br>        factory.setPort(properties.getPort());<br>        return factory.createListener();<br>    }<br><br>    @Bean<br>    public DataConnectionConfigurationFactoryBean dataConnectionConfigurationFactory() {<br>        DataConnectionConfigurationFactoryBean connectionConfigurationFactoryBean = new DataConnectionConfigurationFactoryBean();<br>        connectionConfigurationFactoryBean.setPassivePorts(&quot;2122-2199&quot;);<br>        return connectionConfigurationFactoryBean;<br>    }<br>}</pre><p>In the configuration above, we create a few beans required for the FTP server.</p><p><strong>DataConnectionConfigurationBean </strong>defines a configuration of a range of passive ports available for a data channel. We define the range of ports between 2122 and 2199. I chose the passive mode for FTP because it allows easy managing of the open ports behind a firewall.</p><p><strong>Listener</strong> bean is responsible for waiting for incoming socket requests and kicking off sessions. The <strong>Listener </strong>implementation is based on NIO sockets. <strong>ListenerFactory </strong>accepts a port for a control channel and configuration for the data channel and finally <strong>factory.createListener()</strong> creates the instance of <strong>Listener.</strong></p><p><strong>ConnectionConfigFactoryBean</strong> defines a configuration for the control socket connections. The factory grants you to specify such restrictions as the number of concurrent logged in users, the maximum number of threads the server is allowed to create for processing client requests or enabling/disabling anonymous logins at the server.</p><p>Final bean is <strong>FtpServerBean</strong>. This bean gathers all the instances together to create an FTP server instance. Now you are ready to launch it. This is the minimum required to run Apache FtpServer as a Spring Boot application.</p><p>In the next article, I will describe user authentication and mapping of an S3 bucket as a file system for FTP.</p><p>I hope you like it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67b3362289bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>