Giriş
Yarı bitmiş nesnenin clone'lanması içindir. Şeklen şöyle
Yarı bitmiş nesnenin clone'lanması içindir. Şeklen şöyle
Zip Olarak KurulumThe Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.
FROM tomcat:9.0.64-jre11 (the chosen DockerHub image)
ADD target/provman.war /usr/local/tomcat/webapps/
(The relative location of your WAR file)
EXPOSE 8080 (The port that the Docker container will listen to)
Çalıştırmak için şöyle yaparızdocker build -t provman . (don’t forget the dot!)
docker run -p 80:8080 provman
From tomcat
COPY ./target/hello-world.war /usr/local/tomcat/webapps
JNDI ayarı şöyle yapılır.NOTE - The default data source support in Tomcat is based on the DBCP connection pool from the Commons project. However, it is possible to use any other connection pool that implements javax.sql.DataSource, by writing your own custom resource factory, as described below.
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/eatST">
<Resource
name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="root"
password="123"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test?
useUnicode=true&characterEncoding=UTF8"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
/>
</Context>
catalina.properties dosyasındaki değerleri kullanarak şöyle yaparız.<Resource name="${tomcat.dbpool.ups.quartz.resourcename}" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="${tomcat.dbpool.ups.quartz.connectionurl}"
username="${tomcat.dbpool.ups.quartz.username}"
password="${tomcat.dbpool.ups.quartz.password}"
maxTotal="${tomcat.dbpool.ups.quartz.maxTotal}"
maxIdle="${tomcat.dbpool.ups.quartz.maxIdle}"
minIdle="${tomcat.dbpool.ups.quartz.minIdle}"
maxWaitMillis="${tomcat.dbpool.ups.quartz.maxWaitMillis}"
validationQueryTimeout="${tomcat.dbpool.ups.quartz.validationQueryTimeout}"
testWhileIdle="true"
removeAbandonedOnMaintenance="true"
timeBetweenEvictionRunsMillis="..."
minEvictableIdleTimeMillis="..."
/>
maxIdle bağlantılar boşa çıksa bile kaç tane açık tutulacağını belirtir. 2 olarak belirtmek için şöyle yaparız. maxActive en fazla kaç bağlantı açılacağını belirtir.<Resource
name=XXXXX
type=xxxxx
username=xxxxx
password=xxxxxx
driverClassName=xxxxx
maxIdle=2
url=xxxxx
maxActive=10
/>
<Realm localDataSource="true" debug="99"
className="org.apache.catalina.realm.JDBCRealm" connectionName="user"
connectionPassword="password" connectionURL="jdbc:mysql://localhost:3306/ ccc"
digest="md5" driverName="com.mysql.jdbc.Driver" roleNameCol="role_name"
userCredCol="password" userNameCol="email_id"
userRoleTable="users_list" userTable="user_list_view" />
Combined Realm<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<Manager pathname="" />
Eğer session bilgisini Redis üzerinde saklamak istersek şöyle yaparız.<Manager className="org.redisson.tomcat.RedissonSessionManager"
configPath="${catalina.base}/redisson.conf" readMode="MEMORY" updateMode="DEFAULT"/>
export CATALINA_OPTS=-Xms16m -Xmx256m;catalina.bat dosyası ayarları
set JAVA_OPTS="-Djava.library.path=/usr/tomcat/shared/lib"Bir diğer örnekte ise gelen HTTP isteklerini loglamak mümkün.
In 2005, Dr. Peter Rodgers addressed micro web services during a presentation at a Web Services Edge conference, where the first generation of micro web services was based on service-oriented architecture (SOA). SOA is a "self-contained" software module that performs as a task, and this allows the service to communicate based on SOAP (Simple Object Access Protocol). The main SOAP idea is, "Do the simplest thing possible."
When the concept of a Service Oriented Architecture was launched, the idea was that if you build a service that provides a common function, it would be a waste to keep it from others in the organization. The underlying premise is that writing software is expensive, and multiple implementations allow for different interpretations of what actual services should be provided. By making your services available to the entire organisation you get a single source of truth, and nobody needs to re-invent the wheel. As such, SOA is more about responsibilities and where they lie in the organization, rather than things like application size and the technologies used.
Business value over technical strategyStrategic goals over project-specific benefitsIntrinsic interoperability over custom integrationShared services over specific-purpose implementationsFlexibility over optimizationEvolutionary refinement over pursuit of initial perfection
Applying service-orientation results in units of software partitioned into discrete, autonomous, and network-accessible units, each designed to solve an individual concern. These units qualify as services
In service-oriented architecture (SOA), the service layer is the third layer in a five-abstraction-layer model. The model consists of1. Object layer,2. Component layer,3. Service layer,4. Process layer and5. Enterprise layer.The service layer can be considered as a bridge between the higher and lower layers, and is characterized by a number of services that are carrying out individual business functions.
That said, “doing” SOA has become synonymous with the use of communication protocols like SOAP (the Simple Object Access Protocol) over HTTP, tools like an Enterprise Service Bus, and messages encoded in XML, all of which has little to do with organizational structure, and everything with technology. Looking further along those lines, you could say that Service Oriented Architectures led to the popularization of “Middleware” as a separate layer, and products targeting it became powerful platforms for application integration. It also helped cement the importance of “Enterprise” standards, most notably centralized data dictionaries and Enterprise Architecture.Problemler
With application development you will soon be confronted with the need for change; either the “customers” want a slightly different service interface, or you yourself want to incorporate new functionality and lessons learned. This causes friction, because you can no longer consider the service interface as fully your own, and unexpected (from the viewpoint of the users) changes may break other applications. You are left with basically two alternatives: create different versions of the interface, or coordinate releases over the boundaries of applications or even departments.
This is a classical problem in any distributed system where each node thinks the other nodes are down, while in reality, only the network communication between the nodes is broken. This scenario is more commonly known as a split-brain scenario, and if not handled properly, can lead to more than one node claiming to be a master ... which, in turn, leads to data inconsistencies and corruption.Yıllar önce buna benzer bir problemle karşılaşmıştım ve o zaman bir problemin ismini bilmediğim için düzgün araştırma da yapamamıştım. Problemin ismini öğrenince not almak istedim.
1. Third-party actor (or witness) — an independent application outside of the cluster that can check the availability of all the nodes. Several types of applications can be used for this purpose: load-balancer, Zookeeper, or some other dedicated cluster software. And there are a variety of scenarios of how exactly this application protects the cluster from the split-brain problem. It can check the availability of nodes with heartbeats or register the nodes inside the application, allowing only one primary node to be registered.2. Consensus — the decision about the current leader is based on the nodes’ vote. To promote one of the replicas to be the primary one, it should get a majority of votes, or quorum[3]. This approach is used in MongoDB replica sets. Another example is Hazelcast, which uses the quorum approach for write operations to protect itself from split-brain [4]. When an operation can’t be performed on the sufficient number of cluster members, it raises an exception.3. Generation numbers — there is a generation number available across the cluster, which monotonically increases every time the leader is changed. All the nodes accept only actions performed using the current value of this number. When the old leader is disconnected from other nodes, it will keep the old generation number and won’t be able to apply changes anymore.
But in general, when we are talking about locks, it is better to have only one node in charge of a particular lock in order to prevent the split-brain issue.
ffplay -f lavfi -i testsrc=s=3x3,geq=r='...':g='...':b='...'
1 1111111 1111 1000 00000000 00000000 00000000 00000000 00000000 00000000
|| || |
|<- Exp -><- Mantissa ->
Sign
NaN Hangi Durumlarda Ortaya ÇıkarNaN is a concept defined in IEEE 754 standard for floating-point arithmetic, not being a number is not the same as negative infinity or positive infinity, NaN is used for arithmetic values that cannot be represented, not because they are too small or too large but simply because they don't exist.
Math.sqrt(-2.0)
1/0 = ∞ //too large
log (0) = -∞ //too small
sqrt (-1) = NaN //is not a number, can't be calculated
A NaN is returned (under IEEE 754) in order to continue a computation when a truly undefined (intermediate) result has been obtained. An infinity is returned in order to continue a computation after an overflow has occurred.Örnek
Math.sqrt(Double.NEGATIVE_INFINITY); // NaN
Math.pow(Double.NEGATIVE_INFINITY, 0.5); // Infinity
float qNaN = std::numeric_limits<float>::quiet_NaN();
float result = qNaN - qNaN; //nan verir
Karşılaştırmadouble a = Double.NaN;
double b = Double.NaN;
System.out.println(a == b); // false
System.out.println(a < b); // false
System.out.println(a > b); // false
Visual Studio ile debug ederken NaN iki şekilde görülebilir. İlki -1.#IND000000000000 (indetermined belirsiz) diğeri ise -1.#INF000000000000 (undefined tanımsız) sabitleridir.#include <iostream>
#include <cmath>
#include <algorithm>
int main(int, char**)
{
double one = 1.0, zero = 0.0, nan = std::nan("");
cout << "std::min(1.0, NaN) : " << std::min(one, nan) << endl;
cout << "std::min(NaN, 1.0) : " << std::min(nan, one) << endl;
cout << "std::min_element(1.0, 0.0, NaN) : " << std::min({one, zero, nan}) << endl;
cout << "std::min_element(NaN, 1.0, 0.0) : " << std::min({nan, one, zero}) << endl;
cout << "std::min(0.0, -0.0) : " << std::min(zero, -zero) << endl;
cout << "std::min(-0.0, 0.0) : " << std::min(-zero, zero) << endl;
}
Çıktı olarak şunu alırız$ g++ --std=c++17 ./test.cpp
$ ./a.out
std::min(1.0, NaN) : 1
std::min(NaN, 1.0) : nan
std::min_element(1.0, 0.0, NaN) : 0
std::min_element(NaN, 1.0, 0.0) : nan
std::min(0.0, -0.0) : 0
std::min(-0.0, 0.0) : -0
public unsafe static bool IsNaN(double d)
{
return (*(UInt64*)(&d) & 0x7FFFFFFFFFFFFFFFL) > 0x7FF0000000000000L;
}
veya şöyle yapılabilir. Aşağıdaki kod exponent ve mantissa'yı daha net gösteriyor.inline constexpr bool
isnan(const std::uint32_t bits) noexcept
{
constexpr std::uint32_t exponent = UINT32_C(0x7f800000);
constexpr std::uint32_t mantissa = UINT32_C(0x007fffff);
return ((bits & exponent) == exponent) && ((bits & mantissa) != 0);
}
inline constexpr bool
isnan(const std::uint64_t bits) noexcept
{
constexpr std::uint64_t exponent = UINT64_C(0x7ff0000000000000);
constexpr std::uint64_t mantissa = UINT64_C(0x000fffffffffffff);
return ((bits & exponent) == exponent) && ((bits & mantissa) != 0);
}