7 Ocak 2025 Salı

aws ce - Cost Expolorer Seçeneği

Örnek
Şöyle yaparız
aws ce get-reservation-utilization
Açıklaması şöyle
In AWS, use Cost Explorer to view your reserved instance utilization and identify opportunities for optimization:

10 Aralık 2024 Salı

RocksDB - Embedded Database

WAL
Açıklaması şöyle
By default, RocksDB stores all the writes in a WAL along with the memtable. We turned the WAL off given that our use case was self-healing in nature and no data could have been lost.
multiGet
Açıklaması şöyle
RocksDB gives various ways to read data from the DB. You could either fire a get() command or a multiGet() command. multiGet() is more efficient than multiple get() calls in a loop for several reasons such as lesser thread contention on filter/index cache, lesser number of internal method calls, and better parallelization on the IO for different data blocks.
Autocloseable
Açıklaması şöyle
Every class of RocksDB implements an Autocloseable either directly or indirectly. You need to call the close() on RocksDB’s java objects explicitly (or use try-with-resources) whenever you are done using them to release the actual memory held by RocksDB’s C++ objects. Failure to do so can lead to memory leaks.

6 Aralık 2024 Cuma

OAuth2 Token Exchange

Giriş
Açıklaması şöyle
OAuth Token Exchange is specifically designed to exchange one type of token for another, typically for trusted clients to acquire a different kind of token without requiring user involvement. It’s used for various scenarios where a client application needs a specific token to access a resource, such as swapping an access token for a security token or an identity token.
Açıklaması şöyle
In OAuth Token Exchange, user involvement is minimized or absent. The exchange is typically performed by trusted clients or services that have the necessary authorization, and it’s often done without requiring the user to re-authenticate or provide consent.
Şeklen şöyle

Token Issuer
İlk token'ı veren servis

Token Exchange Service
Açıklaması şöyle
The token exchange service validates the request, ensuring that the client is authorized to make the exchange. It may also perform additional checks, such as verifying the original access token’s scope or expiration time.
İlk token doğrulandıktan sonra açıklaması şöyle
Once the request is validated, the token exchange service issues the new token and sends it back to the client. The client can now use the newly acquired token to access the resource or perform the desired action. This token is suitable for the specific resource, and the client doesn’t need to undergo a full authentication and authorization process again.
Örnek
Şöyledir
POST /oauth2/token HTTP/1.1
Host: https://localhost:9443
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <base64-encoded-clientId:clientSecret>

grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&subject_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
&subject_token_type=urn:ietf:params:oauth:token-type:access_token
&audience=http://localhost:8080
&resource=resource-server.com/api/resource
&scope=read write
Açıklaması şöyle
Here are the key parameters that should be present in a token exchange request

Grant Type
The grant_type parameter specifies the type of token exchange being requested. In the context of Token Exchange, this is usually set to "urn:ietf:params:oauth:grant-type:token-exchange". This indicates the intent to exchange tokens.

Subject Token
The subject_token parameter contains the token that the client application currently holds and wishes to exchange. This token can be an OAuth access token or another type of token.

Subject Token Type
The subject_token_type parameter specifies the type or format of the subject token. Common values include "urn:ietf:params:oauth:token-type:access_token" for OAuth access tokens, but it can vary based on the token being exchanged.

Apart from these, there are a few additional optional parameters

Audience
The audienceparameter specifies the intended audience for the exchanged token. The audience can indicate the resource or service for which the exchanged token will be used.

Resource
The resource parameter is used to specify the target resource server or service where the exchanged token will be presented. It can help ensure that the exchanged token is valid for that resource.

Scope
If scopes are applicable to the token exchange, the scope parameter can be used to define the desired permissions associated with the exchanged token. The scope value may restrict the actions the token can perform.

29 Kasım 2024 Cuma

DO-278A

Giriş
Açıklaması şöyle
DO-278 was updated to DO-278A by the RTCA SC-205 committee and released in December of 2011.
DO-278A sertifikasyonu CNS/ATM (Communication, Navigation, Surveillance, and Air Traffic Management) sistemlerinde kullanılıyor. 

Service History
Açıklaması şöyle
CNS/ATM Systems often have significant non-certified legacy software/hardware that was rolled out before DO-278A took effect. Instead of requiring you to start over and redevelop these systems from scratch, DO-278A allows for the concept of “Service History,” where “history” denotes evidence of strong record-keeping. This allows software engineers to see how the system has functioned in the past and in what capacity so they can ensure the systems are still safe to use and not prone to malfunctions or errors. 

25 Ekim 2024 Cuma

Data Migration Strategy

Bir çözüm burada
Step 1: Dual Writes
Her iki veri tabanına da yazılır

Step 2: Migrate Old Data
Eski veri, yeni veri tabanına taşınır.

Step 3: Changing Read Paths
Artık yeni veri tabanından okuma yapılabilir

Step 4: Changing Write Paths
Eski veri tabanına yazma işlevi söndürülür

17 Ekim 2024 Perşembe

Law Of Demeter - A'nın C'ye Erişimi Yönetmesi

Giriş
Bu yöntemde çoğunlukla A nesnesine C'ye erişim için yeni metodlar ekleniyor. Açıklaması şöyle
Instead, give clients restricted access to operations on the collection through messages that you implement. (Smalltalk Best Practice Patterns, Kent Beck)

Instead, offer methods that provide limited, meaningful access to the information in the collections. (Implementation Patterns, Kent Beck)
Örnek
Şu kod yerine
a.getB().getItems()
Şöyle yaparız.
class A {
  private B b;

  void doSomething() {
    b.update();
  }

  Items getItems() {
    return b.getItems();
  }
}
Şöyle kodlarız.
a.getItems()
Örnek 
Reservation->Show->Rows->Seats sınıfların erişmek yerine
int selectedRow =...;
int selectedSeat = ...;
if (show.getRows().get(selectedRow).getSeats().get(selectedSeat)
 .getReservationStatus()) {
{...}
Şöyle yaparız.
int selectedRow = ...;
int selectedSeat = ...;
if (show.isSeatReserved(selectedRow, selectedSeat)) {...}
Örnek
Şöyle yaparız
public class Order {
  private final MutableList<LineItem> lineItems = Lists.mutable.empty();

  public Order addLineItem(String name, double value) {
    this.lineItems.add(new LineItem(name, value));
    return this;
  }

  public void forEachLineItem(Procedure<LineItem> procedure) {
    this.lineItems.forEach(procedure);
  }

  public int totalLineItemCount() {
    return this.lineItems.size();
  }

  public int countOfLineItem(String name) {
    return this.lineItems.count(lineItem -> lineItem.name().equals(name));
  }

  public double totalOrderValue() {
    return this.lineItems.sumOfDouble(LineItem::value);
  }
}

public record LineItem(String name, double value) {}
Bu kodu synchronized hale getirmek istersek karşımızı bir başka problem çıkıyor. 
1. Yeni bir SynchronizedOrder yazmak
2. lineItems nesnesini synchronized  hale getirmek
3. CopyOnWrite yöntemini kullanmak

Bu durumda kod şöyle olur
public record Order(ImmutableBag<LineItem> lineItems) {
  public Order() {
    this(Bags.immutable.empty());
  }

  public Order addLineItem(String name, double value) {
    return new Order(lineItems.newWith(new LineItem(name, value)));
  }

  public double totalOrderValue() {
    return this.lineItems.sumOfDouble(LineItem::value);
  }
}

public record LineItem(String name, double value) {}




15 Ekim 2024 Salı

AWS Athena

Ad-hoc queries on S3 with Some - CTAS. 

Açıklaması şöyle. Burada detaylı bir örnek var
AWS Athena enabled the option to analyze the unstructured, semi-structured, and structured data stored in Amazon S3 using simple SQL queries. In addition, query results can be saved and used for further reference.