<?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[hashtech - Medium]]></title>
        <description><![CDATA[hashtech - Medium]]></description>
        <link>https://medium.com/hashtech?source=rss----d23841e651e6---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>hashtech - Medium</title>
            <link>https://medium.com/hashtech?source=rss----d23841e651e6---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 14:00:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/hashtech" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dynamic Proxy in Java]]></title>
            <link>https://medium.com/hashtech/dynamic-proxy-in-java-56fbfa92c596?source=rss----d23841e651e6---4</link>
            <guid isPermaLink="false">https://medium.com/p/56fbfa92c596</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[mock]]></category>
            <category><![CDATA[dynamic-proxy]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Emre Savcı]]></dc:creator>
            <pubDate>Sat, 20 Apr 2019 11:37:17 GMT</pubDate>
            <atom:updated>2019-04-24T14:46:47.755Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*QdEq4j63utFq9tDCJWvWvA.gif" /></figure><p>In this post I will introduce you proxy pattern, and how you can implement it in java.</p><p>Proxy is a widely used design pattern. Some of the use cases are can be listed as</p><ul><li>Lazy loading in orms (do you ever think how hibernate lazy loading works under the hood)</li><li>Mocking objects (yeah dynamic proxy is here too)</li><li>Intercepting method calls dynamically (like logging before and after execution)</li></ul><p>I will give you a simple example of how to create proxy object for given type of object using Java’s Proxy api.</p><p>We have a class named Test which implements ITest interface.</p><pre>interface ITest {<br>    int testIt();<br>}<br><br>class Test implements ITest {<br>    public int testIt() {<br>        return 11;<br>    }<br>}</pre><p>First we need to create a class which implements <strong>InvocationHandler </strong>interface.</p><pre>class DynamicInvocationHandler implements InvocationHandler {<br><br>    @Override<br>    public Object invoke(Object proxy, Method method, Object[] args)        {<br><br>        if (&quot;testIt&quot;.equals(method.getName())) {<br>            return 5;<br>        }<br><br>        return null;<br>    }<br>}</pre><p>And then we can create our proxy object as below:</p><pre>public class Main {<br>    public static void main(String[] args) {<br>        DynamicInvocationHandler myTestInvocationHandler = new DynamicInvocationHandler();<br><br>        ITest test = (ITest)Proxy.<em>newProxyInstance</em>(Test.class.getClassLoader(), new Class[] {<br>                ITest.class<br>        }, myTestInvocationHandler);<br><br>        System.<em>out</em>.println(test.testIt());<br>    }<br>}</pre><p><strong>Proxy.newProxyInstance</strong> method takes three argument, first is our class loader, second is interface array which implemented by our class and last is invocation handler itself.</p><p>When we run the below example it prints 5 as output.</p><p>One restriction while using Java’s Proxy api, it only proxies objects which implements at least one interface. We have to give second parameter to it.</p><p>With some modifications we can extend this approach to create our dynamic proxy implementation. We can even write our own mocking library.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56fbfa92c596" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hashtech/dynamic-proxy-in-java-56fbfa92c596">Dynamic Proxy in Java</a> was originally published in <a href="https://medium.com/hashtech">hashtech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unit Testing - Spring Boot Controller MultipartFile Request]]></title>
            <link>https://medium.com/hashtech/unit-testing-spring-boot-controller-multipartfile-request-65e0ffcec0e2?source=rss----d23841e651e6---4</link>
            <guid isPermaLink="false">https://medium.com/p/65e0ffcec0e2</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[controller]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Emre Savcı]]></dc:creator>
            <pubDate>Sat, 20 Apr 2019 11:36:27 GMT</pubDate>
            <atom:updated>2018-08-25T08:59:57.081Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, this is my first post of unit testing in spring boot series. In our company writing unit test is a daily work like writing application code. Moreover, it is a part of definition of done in our scrum team.</p><p>I’m not going to tell you what is unit test, what are the benefits of writing unit tests. But some key points should be considered if you are assume writing unit test is waste of time.</p><p>Writing unit tests provides us :</p><ul><li>Makes refactoring easy without breaking any existing logic</li><li>Backward compability of new features</li><li>Forces us to write clean, testable, solid code</li><li>Simplify to understand application parts</li><li>…</li></ul><p>Well in this part I will show you how to write a test for a controller which expects MultipartFile and json body as request. Lets jump to the code.</p><p>This is how our controller looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e34a6954adf4f3fdd5a8ef3213562ae1/href">https://medium.com/media/e34a6954adf4f3fdd5a8ef3213562ae1/href</a></iframe><p>And this is our unit test:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e41454631624759416171f879474a27/href">https://medium.com/media/0e41454631624759416171f879474a27/href</a></iframe><blockquote>And when we type maven clean install in terminal or press run button in Intellij we will see that our test passes.</blockquote><p>Here is the test result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9W844ZyNMH2nL1qYLCJ4Q.png" /></figure><p>Of course, the given example of controller code is not the actually production code, it just an example to show file really reachs to the controller and test passes.</p><p>I hope it helps you to understand how to test a controller which expects multipart file request in spring boot.</p><p>Nice codings :)</p><p><strong>References</strong></p><ul><li><a href="https://www.baeldung.com/spring-boot-testing">Testing in Spring Boot | Baeldung</a></li><li><a href="https://spring.io/guides/gs/testing-web/">Testing the Web Layer</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65e0ffcec0e2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hashtech/unit-testing-spring-boot-controller-multipartfile-request-65e0ffcec0e2">Unit Testing - Spring Boot Controller MultipartFile Request</a> was originally published in <a href="https://medium.com/hashtech">hashtech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Useful git commands while working on]]></title>
            <link>https://medium.com/hashtech/useful-git-commands-while-working-on-fe69ab4c69c5?source=rss----d23841e651e6---4</link>
            <guid isPermaLink="false">https://medium.com/p/fe69ab4c69c5</guid>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Emre Savcı]]></dc:creator>
            <pubDate>Sat, 13 Apr 2019 22:17:42 GMT</pubDate>
            <atom:updated>2018-12-12T16:11:59.831Z</atom:updated>
            <content:encoded><![CDATA[<p>As a developer many of us use git for version control. Here I’m listing most common things I do while working on daily projects.</p><p><strong>1- ) Merging a branch into current branch</strong></p><p>Sometimes we need to merge a branch into our current branch and resolve some conflicts and push it back. It mainly occurs when we have seperate feature branchs and one of it merges into develop before ours.</p><p>Lets say we want to merge our develop branch into master. Our develop branch has a new commit different from master:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*eejVVBFTLDVSrgzhf09Isw.png" /></figure><p>We checkout to branch master and merge develop into current branch.</p><pre>git checkout master<br>git merge develop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*BfOgVGbkcv7NervuGnqf5g.png" /></figure><p>We see now master synced with develop.</p><p><strong>2 - ) Setting an upstream branch for a local branch</strong></p><p>We use jira to track our issues, and we create branchs from inside an issue to link it together. Stash generate a name which related with issue title and assigsns it to created branch. But if we want to give another name to our local branch somehow we need to link it to remote branch.</p><pre>git branch --set-upstream-to origin/branch-name</pre><p><strong>3 - ) Changing git remote url</strong></p><p>I encountered this situation when I clone an open source project from github without forking it. I need to set origin url as my github fork.</p><pre>git remote set-url origin <a href="https://github.com/USERNAME/REPOSITORY.git">https://github.com/USERNAME/REPOSITORY.git</a></pre><p><strong>4 - ) Rebase &amp; Changing last commit message</strong></p><p>We encounter a situation that we may want to change commit message of a previous commit. Once we learn rebase and amending, it is as simple as below.</p><pre>git rebase -i HEAD~1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*39u866cs5lVP9fxqa3aKfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*FMMPoLkgNGuqgLIyWLfPaQ.png" /></figure><p>Git rebase -i opens interactive ui for us. We select the commit with changing <strong>pick </strong>to<strong> edit</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*CB9deJTkfYLOyss9Osnnqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*QhmkCABS_sgo7X1deafLxg.png" /></figure><p>We type :wq for save and quit.</p><p>After that we type</p><pre>git commit --amend</pre><p>and it opens interactive ui. Change commit message from “secon commit” to “secon commit edited”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*beeJ2Hof57MS4DLC1NCSpQ.png" /></figure><p>Again type :wq for save and quit.</p><p>When we finish our job we type:</p><pre>git rebase --continue</pre><p>And in commit history we see that our commit message and commit hash has been changed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*km-4P1oQ3dg9_3UsjdpdcA.png" /></figure><p>When we rebase multiple commits, it creates a new commit. It causes to lost previous commit history.</p><p><strong>5 - ) Reverting last commit</strong></p><p>To revert last commit we have several options:</p><pre>git reset --hard HEAD~1</pre><p>In the above command, git reverts last commit but you need to be careful, it also discards uncommitted changes.</p><p>To prevent this, you can use the below comment to keep uncommitted changes.</p><pre>git reset --soft HEAD~1</pre><p>Example</p><p>Our current git repository has 2 commits</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*fo9zvBPFgQdIaCaOXn2haQ.png" /></figure><p>We change the file but not commit yet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*BiifX6qowBeioxxlZH_MDA.png" /></figure><p>If we want to revert commit <strong>dd5eedfef </strong>and do this while we have uncommitted changes, here what happens after hard reset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*TD2EuEj0y3rPD1hW7p6lkQ.png" /></figure><p>We lost the current uncommitted changes. But if we do same thing with soft reset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*zokBN8ui1-H6xcnYcK1mcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*lGGIIAd8igZrl1kv3Rl-Yw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*EYt8nS64XAj9ZcejbAoZtA.png" /></figure><p>It resets the last commit and keep the changes.</p><p>To follow me on github: <a href="https://github.com/mstrYoda">https://github.com/mstrYoda</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe69ab4c69c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hashtech/useful-git-commands-while-working-on-fe69ab4c69c5">Useful git commands while working on</a> was originally published in <a href="https://medium.com/hashtech">hashtech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Couchbase 101 — Couchbase Nedir?]]></title>
            <link>https://medium.com/hashtech/couchbase-101-couchbase-nedir-87f4051065e6?source=rss----d23841e651e6---4</link>
            <guid isPermaLink="false">https://medium.com/p/87f4051065e6</guid>
            <category><![CDATA[n1ql]]></category>
            <category><![CDATA[couchbase-nedir]]></category>
            <category><![CDATA[couchbase]]></category>
            <category><![CDATA[couchbase-101]]></category>
            <category><![CDATA[couchbase-connectors]]></category>
            <dc:creator><![CDATA[Hüseyin Güner]]></dc:creator>
            <pubDate>Sat, 06 Apr 2019 15:48:21 GMT</pubDate>
            <atom:updated>2021-01-28T10:50:07.791Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="couchbase ile ilgili gÃ¶rsel sonucu" src="https://cdn-images-1.medium.com/proxy/1*2KQ8oqs8P4llH3idiq69Yg.png" /></figure><h3>Couchbase 101 — Couchbase Nedir?</h3><p>Genel olarak bir uygulama geliştirmeye başladığımızda vermemiz gereken kararlardan biri de veritabanı seçimidir. Uygulama niteliklerini en iyi şekilde karşılayan veritabanına karar verir ve geliştirmeye başlarız. Bu yazımda veritabanı seçenekleri arasında karşımıza çıkan bir NoSQL veritabanı olan Couchbase’i incelemeye çalışacağız.</p><p>İlk akla gelen sorulardan biridir elbet, “<em>İyi de neden bildiğimiz SQL varken Couchbase kullanalım?” </em>Pek tabii bu sorunun cevabını değiştiren bir çok kırılım var. Öncelikli olarak uygulama ihtiyaçlarını belirlemeli ve veri modelinize göre bir karar vermelisiniz. Tabii ki bir veritabanının da ihtiyaçları nasıl çözeceği ve maliyeti de bir hayli önemli. O zaman biz yavaştan başlayalım.</p><h3>Nedir bu Couchbase, yenilir mi, içilir mi?</h3><p>Couchbase adını sıkça duymaya başladığımız ve gittikçe popülerleşen döküman ve key-value tabanlı çalışabilen bir NoSQL veritabanıdır. Cluster mimarisi üzerinde çalışır ve verileriniz bir çok node üzerine dağıtılabilir. Nodelar üzerinde ki veriler öncelikli olarak bellekte işlenir ve aynı zamanda bucket türlerine göre veri tutarlılığını sağlamak için diskede yazılır. Yaptığınız sorgulama ve güncelleme işlemler öncelikli olarak bellek üzerinde yapılır. Böylelikle hızlı bir şekilde verilerimize ulaşabilir ve bunlarla ilgili işlemlerimizi yapabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/0*VIejGUPdB5gqfilk.png" /></figure><p>Dilerseniz Couchbase’in ilk akla gelen ve farklı kılan özelliklerinden kısa kısa başlayalım;</p><p>Couchbase’de veriler <strong>Bucket </strong>adı verilen mantıksal yapılar içerisinde saklanır ve bucket özelliklerine göre veri saklama türleri farklılık gösterebilir. Couchbase 3 farklı bucket tipi sunar, bunlar; <strong>Couchbase, Ephemeral ve Memcached.</strong></p><p><strong>CAP<em>(Consistency,Avaiability,Partition Tolerance) </em></strong>teoreminde ki <strong>Consistency<em> </em></strong>ve<strong><em> </em>Avaiability </strong>ilkelerini karşılar. Bkz: <a href="http://www.wikizero.biz/index.php?q=aHR0cHM6Ly9lbi53aWtpcGVkaWEub3JnL3dpa2kvQ0FQX3RoZW9yZW0">CAP Theorem</a></p><p>SQL veritabanlarında veri tutarlılığını sağlamak için sıkça kullandığımız <strong>lock</strong> mekanizmalarını bir çoğumuz kullanmıştır ve belkide sadece bu mekanizmalar için bir NoSQL veritabanı tercih etmiyor olabilirsiniz. Fakat Couchbase dökümanlar üzerinde tuttuğu <strong>CAS </strong>değeri ile <strong>Optimistic</strong> ve <strong>Pesimistic</strong> lock imkanı sunmakta.</p><p>Couchbase’de dökümanlarınız <strong>Json</strong> olarak tutulur. Bunları sorgulamak istediğinizde ise size full-text search arama yapmanıza imkan tanır. Sorgu dili olarak ise SQL’ e çok benzeyen <strong>N1QL</strong>’i kullanır.</p><pre>{<br>  &quot;airportname&quot;: &quot;Brienne Le Chateau&quot;,<br>  &quot;city&quot;: &quot;Brienne-le Chateau&quot;,<br>  &quot;country&quot;: &quot;France&quot;,<br>  &quot;faa&quot;: null,<br>  &quot;geo&quot;: {<br>    &quot;alt&quot;: 381,<br>    &quot;lat&quot;: 48.429764,<br>    &quot;lon&quot;: 4.482222<br>  },<br>  &quot;icao&quot;: &quot;LFFN&quot;,<br>  &quot;id&quot;: 1306,<br>  &quot;type&quot;: &quot;airport&quot;,<br>  &quot;tz&quot;: &quot;Europe/Paris&quot;<br>}</pre><p>Yukarıda örnek bir Couchbase dökümanı görebilirsiniz. Couchbase döküman içerisinde <strong>sub-document</strong> özelliğide sunmakta. Örneğin yukarıda ki döküman tipinde verilerimiz olsun ve <strong>sampleBucket</strong> adlı buckette barınıyor olsun. Bu veriler arasından <strong>geo.alt</strong> değeri <strong>381</strong> olan dökümanlara ulaşmak istediğimizde aşağıda ki gibi basit bir sorgu yeterli olacaktır.</p><pre>select * from sampleBucket where geo.alt = 381</pre><p>Yukarıdaki gibi basit bir veriyi çekmek istediğinizde SQL veritabanlarında ki inner joinleri hatırlayın 🤦‍♂️</p><p>NoSQL veritabanlarında genel olarak dökümanlar güncellendiğinde tüm döküman güncellenir. Bu da zaman zaman can sıkabilmekte. Fakat Couchbase’in sunduğu <strong>sub-document</strong> ile sadece döküman içerisinde ki bir alt dökümanı ya da döküman içerisinde ki bir değeri güncelleyebilirsiniz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*Ba7MvF8NhKx9RyRiHbS2UA.png" /><figcaption>upsert, insert, replace, get, remove Couchbase’de döküman üzerinde işlem yapabileceğiniz 5 temel operasyon.</figcaption></figure><p>Couchbase içerisinde geçici dökümanlar oluşturmak için <strong>TTL</strong> özelliğini sunar. Örneğin bir şifre sıfırlama linki oluşturduğunuzu düşünün ve bunun geçerlilik süresinin 1 saat olması isteniyor. Bu linke ait döküman için vereceğiniz 1 saatlik TTL adeta bunun için biçilmiş bir kaftan</p><p>SQL veritabanlarında çok sık kullandığımız ID değerlerini hatırlıyorsunuzdur. Genellikler ID’leri <strong>auto increment</strong> olarak tanımlarız ve her yeni kayıtta değeri 1 artar. Couchbase’de bu yapı mevcut değil fakat bunun sağlayacak bir şey mevcut o da <strong>counter. </strong>Counter size atomik olarak belirttiğiniz değerlerde bir veri oluşturur. Böylelikle sürekli artan ve eşsiz bir değere sahip olmuş olursunuz bunu SQL’de ki <strong>sequence </strong>olarak düşünebilirsiniz.</p><pre>&gt;&gt;&gt; cb.counter(&#39;counter_id&#39;, delta=20, initial=100).value<br>100L<br>&gt;&gt;&gt; cb.counter(&#39;counter_id&#39;, delta=1).value<br>101L<br>&gt;&gt;&gt; cb.counter(&#39;counter_id&#39;, delta=-50).value<br>51L</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*Efj-G4DU23phLqfZ" /></figure><p>Veritabanlarında yük arttığı zaman uygulanan ilk çözümlerden biride <strong>replicationdır</strong>.</p><blockquote>“Replicayı oluşturalım sorgular ordan aksın” — Bir DBA atasözü.</blockquote><p>Genellikle veritabanları kendi nodeları arasında replication yapabilmekte, hatta bazıları replication içinde ayrı lisans istemekte 🙄. Diğer veritabanlarına replication için ise farklı araçlar gerekmekte. Couchbase’de dilediğiniz bucketin replicationını kolaylıkla oluşturabilirsiniz, hatta XDCR ile farklı platformlar ile replicationda oluşturabilirsiniz. Aşağıda Couchbase’in kendi içinde sunduğu XDCR connectorleri görebilirsiniz.</p><ul><li><a href="https://docs.couchbase.com/elasticsearch-connector/4.0/index.html">Elasticsearch</a></li><li><a href="https://docs.couchbase.com/server/6.0/connectors/hadoop-1.2/hadoop.html">Hadoop</a></li><li><a href="https://docs.couchbase.com/kafka-connector/3.4/index.html">Kafka</a></li><li><a href="https://docs.couchbase.com/spark-connector/2.2/index.html">Spark</a></li><li><a href="https://docs.couchbase.com/talend-connector/index.html">Talend</a></li><li><a href="https://docs.couchbase.com/server/6.0/connectors/odbc-jdbc-drivers.html">SQL (ODBC/JDBC)</a></li></ul><p>Pek tabii indexler, indexler olmadan olmaz. Couchbase’de de sık sorguladığımız alanlar üzerinde index oluşturma imkanımız mevcut. Dökümanların dağıtımları oluşturulan indexlere göre belirlenir. Böylelikle sıkça sorguladığımız dökümanlar daha hızlı bir şekilde bulunur ve getirilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*E6S9nu3Kz8tUnIoI.png" /><figcaption><a href="https://docs.couchbase.com/server/5.5/performance/index-scans.html">https://docs.couchbase.com/server/5.5/performance/index-scans.html</a></figcaption></figure><p>Bu yazımda sizlere Couchbase’ 101 seviyesinde anlatmaya çalıştım, ilerleyen yazılarda görüşmek üzere 🙋‍♂️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87f4051065e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hashtech/couchbase-101-couchbase-nedir-87f4051065e6">Couchbase 101 — Couchbase Nedir?</a> was originally published in <a href="https://medium.com/hashtech">hashtech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java ile Aws Lambda Kullanımı]]></title>
            <link>https://medium.com/hashtech/java-ile-aws-lambda-kullan%C4%B1m%C4%B1-60e381032637?source=rss----d23841e651e6---4</link>
            <guid isPermaLink="false">https://medium.com/p/60e381032637</guid>
            <category><![CDATA[cloud-functions]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Emre Savcı]]></dc:creator>
            <pubDate>Mon, 25 Mar 2019 18:40:53 GMT</pubDate>
            <atom:updated>2019-03-25T18:31:03.383Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/951/0*WmHApC9I2G-MHJzk.png" /></figure><p>Merhabalar, bu yazımda java ile yazılmış bir uygulamayı aws üzerinde lambda function olarak çalıştırmayı ve CloudWatch events ile tetiklemeyi göstereceğim.</p><p>Öncelikle aws managemenet console a girip <strong>lambda </strong>araması yapalım ve lambda oluşturmak için ilgili sayfaya geçelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oUJ0hWHSJtDfZ_9R46TdWA.png" /></figure><p>Bu ekranda mevcut lambda functionlarımızı görüyoruz. Yeni bir lambda function oluşturmak için sağ üst taraftaki <strong>Create function</strong> butonuna basalım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MpkK4WUcZWhVo62GNwRqLQ.png" /></figure><p>Burada lambda functionımıza bir isim verip runtime seçeneklerinden Java 8 i seçelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2DTt9c5_gdHElJlUhhvJdg.png" /></figure><p>Create adımından sonra aşağıdaki gibi bir ekran karşınıza gelecek. Sonraki adımlarda bu ekran üzerinden lambda functionımız için gerekli ayarları yapacağız.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MD2tX8Pd2ZWYaXdLeyKabw.png" /></figure><p>Lambda functionımızı tetikleyecek cron ayarlarını yapmak için Management console -&gt; CloudWatch -&gt; Events -&gt; Rules kısmından yeni bir rule oluşturalım. Ben önceden bu işlemi yaptığım için lambda functionıma bağlı bir CloudWatch Event gözüküyor.</p><p>Sol tarafta <strong>Schedule </strong>seçeneği ile cron ayarımızı yapıyoruz. Sağ tarafta tetiklenecek lambda functionımızı seçiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXSQX4n_aj9-DnKr1eLeaw.png" /></figure><p>Şimdi lambda functionımız için bir java projesi oluşturalım ve pom.xml içerisine <strong>aws-lambda-java-core</strong> dependency olarak ekleyelim.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;<br>         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br>         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;<br>    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br><br>    &lt;groupId&gt;groupId&lt;/groupId&gt;<br>    &lt;artifactId&gt;gob2c-exchangerate-lambda&lt;/artifactId&gt;<br>    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;<br>    &lt;build&gt;<br>        &lt;plugins&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;<br>                &lt;configuration&gt;<br>                    &lt;source&gt;1.8&lt;/source&gt;<br>                    &lt;target&gt;1.8&lt;/target&gt;<br>                &lt;/configuration&gt;<br>            &lt;/plugin&gt;<br><br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>                &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;<br>                &lt;version&gt;2.3&lt;/version&gt;<br>                &lt;configuration&gt;<br>                    &lt;createDependencyReducedPom&gt;false&lt;/createDependencyReducedPom&gt;<br>                &lt;/configuration&gt;<br>                &lt;executions&gt;<br>                    &lt;execution&gt;<br>                        &lt;phase&gt;package&lt;/phase&gt;<br>                        &lt;goals&gt;<br>                            &lt;goal&gt;shade&lt;/goal&gt;<br>                        &lt;/goals&gt;<br>                    &lt;/execution&gt;<br>                &lt;/executions&gt;<br>            &lt;/plugin&gt;<br>        &lt;/plugins&gt;<br>    &lt;/build&gt;<br><br>    &lt;dependencies&gt;<br><strong>        &lt;dependency&gt;<br>            &lt;groupId&gt;com.amazonaws&lt;/groupId&gt;<br>            &lt;artifactId&gt;aws-lambda-java-core&lt;/artifactId&gt;<br>            &lt;version&gt;1.1.0&lt;/version&gt;<br>        &lt;/dependency&gt;</strong><br>    &lt;/dependencies&gt;<br><br>&lt;/project&gt;</pre><p>Lambda functionın çalışacağı class <strong>RequestHandler </strong>interface ini implement etmeli. Örneğin request olarak string alan ve response olarak string dönen bir function için aşağıdaki şekilde implement edebiliriz.</p><pre>package com.test;</pre><pre>import com.amazonaws.services.lambda.runtime.Context;<br>import com.amazonaws.services.lambda.runtime.RequestHandler;</pre><pre>public class Main implements RequestHandler&lt;String, String&gt; {</pre><pre>    @Override<br>    public String handleRequest(String s, Context context) {</pre><pre>       context.getLogger().log(&quot;request string : &quot; + s);<br>       context.getLogger().log(&quot;log from test&quot;);</pre><pre>        return &quot;test&quot;;<br>    }</pre><pre>}</pre><p>Yazdığımız projeyi aws ye yüklemek için <strong>mvn package </strong>komutu ile jar dosyamızı oluşturalım.</p><p>Lambda function ekranına geri gelelim ve upload kısmından oluşturduğumuz jar dosyamızı upload edelim. Burada önemli nokta, <strong>Handler </strong>kısmında yazan yere kendi package ve class ismini yazmamız gerekiyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0wiX-2RBF5sM2gYlfFCRCQ.png" /></figure><p>Basic settings bölümünden lambda için timeout belirtebiliyoruz. Ben test amaçlı 8 saniye olarak ayarladım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GbzjNu7cYEGiEQY5WK0sBA.png" /></figure><p>Şimdi sağ üstte bulunan <strong>Test </strong>butonu ile lambda functionımızı test edelim. Test butonuna bastığımızda test eventi oluşturmamızı istiyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VffsnvONrb0YU6bnVyM9Lw.png" /></figure><p>Save diyip functionımızı invoke ediyoruz ve output olarak başarılı bir execution result görüyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jb-2PUnVkG2Bg2H7tIE9ag.png" /></figure><p>Burada <strong>logs</strong> kısmından lambda functionımızın loglarını görebiliriz. Test olarak gönderdiğimiz “test event” parametresi loglarımız arasında bulunuyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iqD3gbXDffYzICEKAWACA.png" /></figure><p>Aws aylık 1 milyon lambda isteğini ücretsiz sunuyor ve sonraki her 1 milyon isteği 0.20 dolar fiyatlandırıyor. Detaylı fiyatlandırma için :</p><p><a href="https://aws.amazon.com/tr/lambda/pricing/">https://aws.amazon.com/tr/lambda/pricing/</a></p><p>Hızlı bir başlangıç oldu, aws maceralarımıza ilerleyen yazılarda devam edeceğiz.</p><p>Herkese iyi kodlamalar.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60e381032637" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hashtech/java-ile-aws-lambda-kullan%C4%B1m%C4%B1-60e381032637">Java ile Aws Lambda Kullanımı</a> was originally published in <a href="https://medium.com/hashtech">hashtech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ES101 — Elasticsearch Mimarisi]]></title>
            <link>https://medium.com/hashtech/https-medium-com-hltsydmr-elasticsearch-es101-4b852dcb9763?source=rss----d23841e651e6---4</link>
            <guid isPermaLink="false">https://medium.com/p/4b852dcb9763</guid>
            <category><![CDATA[lucene]]></category>
            <category><![CDATA[index]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[full-text-search]]></category>
            <dc:creator><![CDATA[Halit Soydemir]]></dc:creator>
            <pubDate>Sun, 17 Feb 2019 19:23:00 GMT</pubDate>
            <atom:updated>2019-02-18T09:15:18.023Z</atom:updated>
            <content:encoded><![CDATA[<h3>ES101 — Elasticsearch Mimarisi</h3><p>İlk blog yazım olarak ES101 sizlerle, yazı umarım açıklayıcı ve yararlı olmuştur. İçerik daha çok elasticsearch’ün mimarisi hakkında genel bilgi içermektedir. Genel olarak başlıklar şöyledir; index, inverted index, shard, lucene, segment. Evet ilk başta bu kavramlar çok karışık gelmektedir ancak görseller ile daha konuların oturduğunu söyleyebilirim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_TtFxk6L0SHIscV0.jpg" /><figcaption><a href="https://www.bogotobogo.com/Hadoop/ELK/images/ElasticSearch/Shards-Nodes-Clusters.jpg">https://www.bogotobogo.com/Hadoop/ELK/images/ElasticSearch/Shards-Nodes-Clusters.jpg</a></figcaption></figure><p>Elasticsearch, lucene java kütüphanesi üzerine kurulmuş distributed arama motorudur. Elasticsearch’e gönderilen datayı lucene görür ve saklar.</p><p>NoSQL yapıları 4 temel başlıkta ayrılır:</p><ul><li>document-based</li><li>key-value</li><li>graph-based</li><li>column-based</li></ul><p>Elasticsearch burada<strong> document-based</strong> NoSQL grubuna girmektedir, <strong>key-value</strong> yapısına benzemektedir ancak value kısmında döküman’ı tutmaktadır.</p><h3>Index nedir?</h3><p>Aslında her bir index Relational Database’ler deki tablo yapısına denk geliyor diyebiliriz. Index’i oluştururken iki yöntem vardır biri manuel olarak bizim oluşturmamız, ikincisi ise bunu elasticsearch’e bıraktığımız yöntemdir. Temelde bir index bir veya birden fazla shard’ı temsil eden alan adıdır. Indexlemek(<strong>indexing</strong>) kavramı ise; datayı elasticsearch’e göndermek(verinin geri istenebilecek şekilde saklanması ve arama yapılmabileceği) anlamına gelmektedir.</p><ol><li>Yöntem</li></ol><blockquote>POST /users diyerek manuel oluşturmak</blockquote><p>2. Yöntem</p><blockquote>POST /users/user/1 diyerek yeni bir döküman eklerken, elasticsearch mappingleri kendisi yaparak bir index oluşturur</blockquote><p>İndex’i oluşturan bileşenler; mappings, settings ve aliases’dır.</p><pre>{<br>  &quot;index-name&quot;: {<br>    &quot;<strong>aliases</strong>&quot;: {},<br>    &quot;<strong>mappings</strong>&quot;: {<br>      &quot;user&quot;: {<br>        &quot;properties&quot;: {<br>          &quot;name&quot;: {<br>            &quot;type&quot;: &quot;string&quot;<br>          }<br>        }<br>      }<br>    },<br>    &quot;<strong>settings</strong>&quot;: {<br>      &quot;index&quot;: {<br>        &quot;creation_date&quot;: &quot;1447004861339&quot;,<br>        &quot;uuid&quot;: &quot;KzZW7zJyTPavy4n1TTeNkg&quot;,<br>        &quot;number_of_replicas&quot;: &quot;1&quot;,<br>        &quot;number_of_shards&quot;: &quot;5&quot;,<br>        &quot;version&quot;: {<br>          &quot;created&quot;: &quot;1070399&quot;<br>        }<br>      }<br>    }<br>  }<br>}</pre><p><strong>Aliases, </strong>index’e verdiğimiz takma isimlerdir ve bize uygulamanın kesinti yaşamadan index değiştirebilmesini sağlar.</p><p><strong>Mappings</strong>, index içerisinde saklanacak veri yapısını tutmaktadır, aslında RDB’lerdeki tablo yapısı olarak düşünülebilir. Her ne kadar tutulan data json yapısında olarak bize esnek bir yapı sağlasada, data yapısını vermek bize performans sağlar.</p><p><strong>Settings</strong> içerisinde index ile ilgili ayarlar bulunmaktadır, örnek olarak; “kaç shard?”, “replika sayısı kaç?” gibi soruların cevapları buradan ayarlanmaktadır. Bunun yanında analyzer bilgileride burada bulunmaktadır. Analyzer da seri işlemleri gerçekleştirerek en son bir çıktı verir elasticsearch için.</p><p><strong>Type, </strong>benzer dökümanlar sınıfıdır diyebiliriz aslında şöyleki, “user” index’ini düşünelim. Bu index altında “admin”,”user” ve ”staff” gibi type’lar oluşturabiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*E3sUOdBTG9wzG5b8.png" /><figcaption><a href="https://lucidworks.com/wp-content/uploads/2017/10/segment-merging-bw-1.png">https://lucidworks.com/wp-content/uploads/2017/10/segment-merging-bw-1.png</a></figcaption></figure><h3><strong>Shard nedir?</strong></h3><p>Elasticsearch cluster’ı içerisinde çalışan lucene instance’larını temsil eder ve ayrıyetten lucene index de diyebiliriz. Bir index tek başına bir shard’dan oluşabilir ancak, genellikle index’in büyüyebilmesi ve bir kaç node üzerinde dağıtılabilmesi için bir kaç shard’dan oluşmaktadır. Primary shard döküman için ev sahipliği yapmaktadır, replica shard ise primary’nin bir kopyasıdır ve primary shard down olması durumunda replica shard kullanılır. Ayrıca dökümanı read ederkende replikalar kullanılabilir.(<a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/distrib-read.html">distributed read</a>)</p><p><strong>Replica, </strong>elasticsearch her verinin kopyasını başka makinalara da gönderir, böylece makinalardan bir tanesi down olması durumunda veri kaybı yaşanması engellenir.</p><p>Ayrıca elasticsearch’de consistency level tanımlayarak, indexleme işleminin bitmesini tüm shardlarda indexledikten sonra başarılı olarak dönecek şekilde ayarlayabiliriz.</p><p>Bir elasticsearch index search işlemi yapıldığında, bu arama işlemi tüm shardların tüm segmentlerinde gerçekleşir ve merge olurlar.</p><p>Shard aslında elasticsearch için bir “scaling unit” anlamı taşımaktadır. Örnek olarak; iki elasticsearch index search’ü (herbirine bir shard) ile bir index’in iki shard olması aynı durum çünkü, iki adet lucene index search işlemi gerçekleşir.</p><p>Dökümanları indexlerken, shardlara route olurlar, default olarak round-robin olarak dağıtılır. Index create edilirken verilen shard sayısı daha sonrasında değiştirilemez, bu demek değilki çözüm yolu yok. Bu durumda <strong>index shrink</strong> yada <strong>reindex</strong> işlemleri gerçekleştirilerek shard sayısı değiştirilebilir.</p><p><strong>Index shrink</strong> işlemi shard sayısını azaltmak için kullanılır, burada önemli olan bir nokta ise; primary shard olarak düşünürsek yeni shard sayısı eski shard sayısının çarpanları olabilir. Örnek olarak, 15 primary shard’lı bir index düşünür isek, shrink işlemi ile primary shard sayısı 1,3,5 den biri olabilir. Shrink işleminde, öncelikle aynı özelliklerde sadece shard sayısını azaltarak yeni bir index oluşturur, daha sonra eğer dosya sistemi izin veriyorsa segmentleri yeni index’e hard-link yapar(dosya sistemi izin vermiyor ise yeni index’e kopyalar ve bu süreç daha uzun sürer). Daha sonrasında ise yeni index’i eskisinin yerine koyarak işlemi tamamlar.</p><p><strong>Reindex</strong> işleminde ise, yeni index’e eski indexteki konfigurasyonlar aktarılmaz ve yeni konfigurasyonlar ile index oluşturduktan sonra, dökümanlar yeni index’e kopyalanır.</p><h3>Lucene nedir?</h3><p>Apache tarafından geliştirilen java tabanlı full-text search olanağı sağlayan bir kütüphanedir. Bir döküman basit olarak “field:value” olarak eşlenir. Lucene field’ın string yada tarih vb bir formatta olmasını önemsemez, opaque-bytes olarak kabul eder.</p><p>Lucene’de biz bir dökümanı indexlediğimiz zaman, her bir alan(field)için değerler(values) inverted index’e eklenir ve isteğe bağlı olarak orjinal değerler daha sonrada ulaşılabilir olması için değişmeden de saklanabilir.</p><p>Elasticsearch’teki type kavramı’nın lucene’de tam karşılığı yoktur ancak, lucene’de bu veriler bir dökümanın meta datasında <strong>_type </strong>diye bir alanda tutulur ve özel bir arama yaparken; lucene <strong>_type</strong> alanına göre filtreleme yapar.</p><p>Lucene üzerinde mapping diye bir kavram da bulunmamaktadır, mapping elasticsearch’ün karışık json dökümanının lucene’in beklediği bir yapıya çevrilmesi için kullanılır.</p><p>Lucene her ne kadar transaction sağlasa bile, elasticsearch bunu sağlamaz.</p><h3>Inverted Index Nedir?</h3><p>Aslında inverted-index ile; terimler-döküman ilişkisini bir yerde tuttuğumuzu düşünürsek, bir term ile search işlemi gerçekleşirken bu term’e denk gelen dökümanlara direkt erişebilirsiniz.</p><p>Inverted-Index’te önemli noktalardan bir tanesi ise <strong>analyzer’</strong>lardır. Çeşitli tokenizer ve filter’lar üzerinden geçtikten sonra inverted index’e kayıt edilir.</p><p>Örnek olarak; standart tokenizer burada text’i split etti aslında, lowercase filter ise hepsini küçük harfe çevirdi ve stopwords ise bazı kelimeleri çıkarttı. En sonun da en sağdaki gibi bir inverted-index oluştu, bu örnekte bir dökümanda birden fazla yerde aynı kelimenin geçme durumuda ele alınarak(bilgisayarın {1:1,1:14} gibi)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*qyX6a2F2VOYt11ecXvVwiw.png" /><figcaption><a href="http://elasticsearch.kulekci.net/assets/img/inverted-index.png">http://elasticsearch.kulekci.net/assets/img/inverted-index.png</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*jAa78FeJakICX7iICdd8eA.png" /></figure><p>Yukarıdaki görsel elastic mimarisindeki hiyerarşiyi anlamanızda biraz daha yardımcı olacaktır. <strong>Cluster</strong> içerisinde <strong>node</strong>’lar, ve onların içerisinde ise <strong>shard</strong>’lar bulunmaktadır. Shard’lar nodelara dağıtılırken primary ve secondary shardlar farklı makinelere dağıtılarak olası problemleri minimize etmek gerekmektedir. Shard’ların da içerisinde <strong>segment</strong>’ler bulunmaktadır.</p><h3><strong>Segment Nedir?</strong></h3><p>Her shard birden fazla segment’e sahiptir ve her segment bir inverted indextir. Bir shard üzerinde yapılan arama sırasıyla her bir segmentte aranacaktır ve sonra elde edilen bu sonuçlar shard bazında oluşan, sonuçlar kümesinde toplanacaktır.</p><p>Bir dökümanı indexlerken, elasticsearch onları öncelikle transaction log’a yazacak(data kaybı olmaması için) ve memoryde(disk’e göre daha performanslı olması için) toplayacaktır. Daha sonra ise index.refresh_interval süresinde(default 1sn) bir diskte yeni bir segment oluşturarak veriyi segment içerisinde search edilebilir hale getirir ve refresh eder. Şu an veri arama yapılabilir(<strong>searchable</strong>) haldedir. Ancak yeni oluşan bu segment henüz <strong>fsync(flush)</strong> edilmemiş haldedir, yani halen kaybolma riskine sahiptir. Elasticsearch sık sık flush işlemini gerçekleştirir, ve bu işlem sonrasında veri artık işlenmiştir(indexlenmiştir) ve sonrasında transaction log’dan silinir.</p><p>Segment sayısı optimize olmalıdır, çünkü fazla segment olması daha performanslı olması anlamına gelmez. Ne kadar çok segment olur ise aramalar o kadar uzun sürer, çünkü segmentlerden dönen arama sonuçları shardda toplanırken merge maliyeti devreye girer.</p><p>Peki sürekli segment oluşturuyoruz o zaman nasıl optimize etmeliyiz derseniz, elasticsearch arkaplanda gerçekleştirdiği <strong>merge processsler</strong> sayesinde benzer büyüklükteki segmentleri birleştirerek daha büyük segmentler elde eder ve bunu diske yazdıktan sonra eskilerini siler. Merge operasyonları için ise birden fazla policy bulunmaktadır (<a href="https://lucene.apache.org/core/6_2_1/core/org/apache/lucene/index/MergePolicy.html">Policy Tipleri</a>, <a href="http://blog.mikemccandless.com/2011/02/visualizing-lucenes-segment-merges.html">Örnekler</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EomFTuTkX-68s9k8.png" /><figcaption><a href="https://lucidworks.com/wp-content/uploads/2017/10/segment-merging-bw-1.png">https://lucidworks.com/wp-content/uploads/2017/10/segment-merging-bw-1.png</a></figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYW0bOvLp72E&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYW0bOvLp72E&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FYW0bOvLp72E%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ccb827c618be083fd176d63ef99e118/href">https://medium.com/media/9ccb827c618be083fd176d63ef99e118/href</a></iframe><p>Segmentler immutable’dır(değişmezler), döküman update edildiğinde ise eski döküman silindi olarak işaretlenir ve yeni bir döküman ekleniyormuş gibi işlem yapılır.</p><p>Yapılan merge processler esnasında ayrıyetten silindi olarak işaretlenen dökümanlarda çıkartılır. Daha fazla döküman eklenmesi herzaman index size’ının artması anlamına gelmez. Nasıl derseniz; silindi olarak işaretlenenler merge process’te silindiği için böyle bir durumla karşılaşılma ihtimalide bulunmaktadır.</p><p><strong>Concurrent merge scheduling</strong>; merge işlemleri ayrı threadlerde gerçekleşir, maximum thread count’a gelindiğinde ise available olana dek bekler ve daha sonra devam eder. Lucene 2.3 versiyonundan önce her döküman ekleme işleminde “<strong>tiny segment</strong>”ler oluşturuluyordu, ancak artık “<strong>documents writer</strong>” ile döküman topluluğu (batch of documents) in-memory segmentlerde tutulur. Ayrıca lucene versiyon 4&#39;ten sonra bu işlemlerin her biri bir thread’de de gerçekleşebilir, böylece conurrent flushing yaparak indexing performansının artışını sağlar, daha eski versiyonlarda ise; indexing flush’ın bitmesini bekler.</p><p>Indexing throughput oldukça önemli bir faktör, reindexing yaparken; küçük segmentleri flushing ve merging yapmak pek efektif değildir. Bu yüzden bu esnada geçici olarak “refresh interval”ı arttırmak yada refreshing’i kapatmak iyi bir yol olabilir.</p><h3><strong>Referanslar</strong></h3><ul><li><a href="http://blog.mikemccandless.com/2011/02/visualizing-lucenes-segment-merges.html">Visualizing Lucene&#39;s segment merges</a></li><li><a href="https://elasticsearch.kulekci.net/">Haydar KULEKCI - Elasticsearch Türkçe Blog - Yazılar</a></li><li><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html">Elastic fundamentals | Elastic Docs</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b852dcb9763" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hashtech/https-medium-com-hltsydmr-elasticsearch-es101-4b852dcb9763">ES101 — Elasticsearch Mimarisi</a> was originally published in <a href="https://medium.com/hashtech">hashtech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>